Page 1 of 1

Alert when Value not changed

Posted: Wed Apr 29, 2015 9:39 am
by jstoddart
We have a few checks implemented using the Oracle Query plugin which return counts from Db tables e.g.

select count(*) from esjkeprd.ej_bulk_comm_send ebcs, esjkeprd.ej_bulk_communication ebc where ebc.id=ebcs.communication_id and (ebcs.is_sent!='y' and ebcs.is_sent!='f') and ebcs.is_ready!='f' and ebc.method_id=1328: 2604

The issue we have is that our customer has a bulk send function and can send out thousands of records in one batch, the fact there is a big number outstanding is not an issue as it will eventually clear.

Is there a way we can configure Nagios to alert if the number returned is the same more than once i.e. the queue is not clearing?

Re: Alert when Value not changed

Posted: Wed Apr 29, 2015 10:47 am
by jdalrymple
By default Nagios plugins are without state. It can be pretty easy to add with a wrapper though:

wrapper.sh

Code: Select all

#!/bin/bash

tmpfile="/tmp/nagioscheckfoo.tmp"
nrpe="/usr/local/nagios/libexec/check_nrpe"
check="$1"

newrun="$($check | sed 's/[^0-9]*//')"
oldrun="$(head -1 $tmpfile)"
echo $newrun > $tmpfile

if [ "$newrun" -eq "$oldrun" ]; then
        output=2
        status="CRITICAL - Nothing has changed"
else
        output=0
        status="OK - The data seems to have changed"
fi

echo $status
exit $output

Code: Select all

[root@localhost libexec]# ./wrapper.sh '/usr/local/nagios/libexec/check_dummy 0 12345'
CRITICAL - Nothing has changed
[root@localhost libexec]# ./wrapper.sh '/usr/local/nagios/libexec/check_dummy 0 12345'
CRITICAL - Nothing has changed
[root@localhost libexec]# ./wrapper.sh '/usr/local/nagios/libexec/check_dummy 0 12346'
OK - The data seems to have changed

Re: Alert when Value not changed

Posted: Fri May 01, 2015 3:53 am
by jstoddart
Excellent, thanks will give that a try

Re: Alert when Value not changed

Posted: Fri May 01, 2015 12:36 pm
by abrist
Let us know if this works for you or if you have any follow up questions.

Re: Alert when Value not changed

Posted: Fri May 01, 2015 12:37 pm
by jdalrymple
Happy to help - that's the beauty of Nagios. If it doesn't already do what you want, it's usually pretty easy to change its behavior.

Let us know if this doesn't work out for you.