Page 1 of 1

Alerting each time a Value Changes

Posted: Thu Jan 09, 2020 9:31 am
by jaimie.livingston
I have a set of devices that produce a device status string that is either "ACTIVE" or "STANDBY". Both values are valid (i.e. either is OK -- there's nothing wrong), but a notification email needs to be sent whenever the value changes from ACTIVE to STANDBY and vice verse. I don't want the check status to change from OK to WARNING/CRITICAL when the value changes. I just want to send a notification.

Is there a way to do this using a stock plugin or setting?

Thanks,

Jaimie Livingston

Re: Alerting each time a Value Changes

Posted: Thu Jan 09, 2020 10:24 am
by tacolover101
it sounds like you're adding a layer of abstraction to alert even when state is OK (or '0' to nagios).

let me break this down a bit further.

nagios looks at the exit code returned to determine what the status is, which could be 0,1,2,3. this then translate to ok, warning, critical, unknown. these codes are what singal to nagios whether it should take action based on a change, not the text in the result.

now in your case, the exit code is going to remain 0 since everything is in an OK state.

since the exit code to nagios isn't going to change, you'll need to handle the email alert part on your own. this can still be done though. let's say you're using a plugin called check_http. you'll want to write a wrapper to run this, and evaluate the result.

Code: Select all

#!/bin/bash
command=$(./check_http -H google.com)
if [[ $command == *"STANDBY"* ]]; then
#send message
/usr/bin/mail blah blah blah
fi
#preserve output and prior exit
echo $command
exit $?
this isn't tested, but hopefully provides an idea of what needs to happen


another option is creating a service check to watch the text result from the plugin, which could then be your email trigger.

Re: Alerting each time a Value Changes

Posted: Thu Jan 09, 2020 11:14 am
by jaimie.livingston
Thank you for your answer. I am already familiar with using wrappers and custom event handlers for this.

That said, it's such a common requirement for monitoring many types of devices with similar redundancy states -- firewalls, routers, load-balancers, mail gateways, DB servers, etc -- that it seems there should be an out of the box method, vs every customer who needs this having to create their own custom plug-ins...

Maybe a good option for a feature request...

Jaimie Livingston

Re: Alerting each time a Value Changes

Posted: Thu Jan 09, 2020 11:36 am
by benjaminsmith
Hi Jaimie,
Maybe a good option for a feature request...
If you 'd like to directly submit a feature request, you can do so on the Nagios Core GitHub site.

https://github.com/NagiosEnterprises/nagioscore/issues