Change notification Downtime

Hello guys,

Let me explain my issue:

So I have a host that is UP and running fine.
Suddenly, it goes down at 10:55:00 (example)
After that, the soft check goes 1/3…2/3…3/3 (1 minute delay during each soft check)
When it pings 3 times, the host is definitely down at 10:58:00.

When I receive the notification via e-mail, I’ll get the following:

Dummy is DOWN!

Info: PING CRITICAL - Packet loss = 100%

When: 2019-02-11 10:58:00 -0200
Host: Dummy

The “When” statement says : 10:58:00, but the host has been down since 10:55 (the first soft check). I know I can simply subtract three minutes on .sh, but what if different hosts have different soft checks delay? How can I change that time?

Thanks.

Hi,

that timestamp refers to the last HARD state being a problem. The default notification scripts take that as longdatetime parameter.

passing it along from the NotificationCommand object

setting a default to the $icinga.long_date_time$ runtime macro.

You could also use host.last_state_change but that returns a unix timestamp. Either you’ll format that inside the notification script, or with something like that in your Notification apply rule.

  vars.notification_date = {{ DateTime(macro("$host.last_state_change$")).to_string() }}

Cheers,
Michael

1 Like

Thanks Michael, it worked indeed!!! Anyway I can ignore the CRITICAL state check? I mean, if the ping fails the state goes directly to DOWN.

Hi,

the ping check only knows about the states OK(0), Warning(1), Critical(2), Unknown(3) coming from the plugin itself.

For host states, this is mapped inside the core into UP and DOWN: https://icinga.com/docs/icinga2/latest/doc/03-monitoring-basics/#check-result-state-mapping

You can just “ignore” the plugin’s output here, and only focus on seeing the DOWN string in the mail’s subject.

Cheers,
Michael

1 Like