Alerting each time a Value Changes

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jaimie.livingston
Posts: 59
Joined: Wed Nov 23, 2016 10:41 am

Alerting each time a Value Changes

Post 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
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Alerting each time a Value Changes

Post 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.
jaimie.livingston
Posts: 59
Joined: Wed Nov 23, 2016 10:41 am

Re: Alerting each time a Value Changes

Post 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
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Alerting each time a Value Changes

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked