Changing service state to OK from the event handler

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
meliezer
Posts: 8
Joined: Thu Aug 20, 2015 7:28 am

Changing service state to OK from the event handler

Post 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è
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Changing service state to OK from the event handler

Post 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.
Former Nagios employee
meliezer
Posts: 8
Joined: Thu Aug 20, 2015 7:28 am

Re: Changing service state to OK from the event handler

Post by meliezer »

I would like to add that the two Nagios servers to compare are located in different countries.
Thank you tmcdonald.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Changing service state to OK from the event handler

Post 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.
Former Nagios employee
meliezer
Posts: 8
Joined: Thu Aug 20, 2015 7:28 am

Re: Changing service state to OK from the event handler

Post 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.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Changing service state to OK from the event handler

Post 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.
meliezer
Posts: 8
Joined: Thu Aug 20, 2015 7:28 am

Re: Changing service state to OK from the event handler

Post 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?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Changing service state to OK from the event handler

Post 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.
Locked