Page 1 of 1

Changing service state to OK from the event handler

Posted: Thu Aug 20, 2015 7:35 am
by meliezer
Hello,
I wonder if it's possible to tell Nagios that actually this service is OK, from the service event handler.
It's an even hander that confronts the status with a second Nagios server, for avoiding false positive alerts.
I can try avoid sending notifications by sending an external command, but I'm not sure Nagios would apply it fast enough.
Anyway, the log shoudln't show a Critical state once the second Nagios doesn't agree.
Any ideas?

Best regards,
Menashè

Re: Changing service state to OK from the event handler

Posted: Thu Aug 20, 2015 9:31 am
by tmcdonald
Event handler running an external command was my first thought. The problem then is that you run into flapping issues potentially. Short of wrapping the check in a script that consults with the other server, I can't think of a good way to do this.

Re: Changing service state to OK from the event handler

Posted: Tue Sep 01, 2015 5:43 am
by meliezer
I would like to add that the two Nagios servers to compare are located in different countries.
Thank you tmcdonald.

Re: Changing service state to OK from the event handler

Posted: Tue Sep 01, 2015 9:13 am
by tmcdonald
That will add some latency, but otherwise shouldn't affect the script too much. You just need some way for them to talk, and that isn't something we can really help with.

Re: Changing service state to OK from the event handler

Posted: Tue Sep 01, 2015 9:31 am
by meliezer
tmcdonald wrote:Event handler running an external command was my first thought. The problem then is that you run into flapping issues potentially. Short of wrapping the check in a script that consults with the other server, I can't think of a good way to do this.
Which external command? Disable globally the notification sending isn't good enough.
I need to disable notifications only for the specific service, or even better: tell my local Nagios that to change service status to OK.
I assume these options are not possible.

Re: Changing service state to OK from the event handler

Posted: Tue Sep 01, 2015 1:00 pm
by jdalrymple
Why not have your event handler just send a passive OK result?

As for:
meliezer wrote:I can try avoid sending notifications by sending an external command, but I'm not sure Nagios would apply it fast enough.
There is:
first_notification_delay: This directive is used to define the number of "time units" to wait before sending out the first problem notification when this service enters a non-OK state. Unless you've changed the interval_length directive from the default value of 60, this number will mean minutes. If you set this value to 0, Nagios will start sending out notifications immediately.

Re: Changing service state to OK from the event handler

Posted: Wed Sep 02, 2015 4:39 am
by meliezer
jdalrymple wrote:Why not have your event handler just send a passive OK result?
Great idea! Thank you!
So, will the service state be affected both by active checks and passive checks (done only once the event handler sends a passive result)?
As for the first_notification_delay, can I simply set it permanently to 2 minutes, assuming that Nagios will process the passive result, so it will not send the notification for CRITICAL state?

Re: Changing service state to OK from the event handler

Posted: Wed Sep 02, 2015 9:52 am
by jdalrymple
Right on the money.

Nagios will process both

Nagios will wait the desired 2 minutes and if the service/host recovers you shouldn't get notified.

Let us know if you experience anything besides the described/desired behavior.