Page 1 of 1
Reversing ssh plugin results for notification an going RED
Posted: Wed Dec 21, 2011 6:23 pm
by JohnFM3
I want Nagios to report RED an send notifications when sshd is running.
Is there any good documentation or explanation on how to accomplish this?
Currently I am running nagios 3.x which came with OpenSuSE 11.4
Thanks,
John
Re: Reversing ssh plugin results for notification an going R
Posted: Thu Dec 22, 2011 6:56 pm
by jsmurphy
You definitely have a knack for finding niches that I don't think anyone has filled

. I think you might need to write your own script but this one should be easy, though we are once again straying into the territory of things I've never tried:
Essentially create a script to invert states, Nagios expects an exit code to determine the state of a service which looks like this:
OK - 0
WARNING - 1
CRITICAL - 2
UNKNOWN - 3
Create a command in Nagios that looks like this $USER1$\check_tcp -H $HOSTADDRESS$ -p 22 | invert.sh
invert.sh in pseudo code would do:
$state = $arg1
if [$state = "OK"] then
print "SSH port listening"
exit 2
else
print "SSH port is closed"
exit 0
fi
Re: Reversing ssh plugin results for notification an going R
Posted: Wed Dec 28, 2011 11:08 am
by JohnFM3
Ok, so after some research I found a plugin which does what is needed for any check_plugin. This was provided to me as a result of a email sent to the Icinga team (a fork of nagios) who uses the nagios plugin's. When you install the extra plugin pack, a utility called NEGATE which has the ability to reverse the out put of a plugin.
An example for check_ping..
negate /usr/local/nagios/libexec/check_ping -H host
**Run check_ping and invert result. Must use full path to plugin**
Finding this is very gratifying an shows just how flexible Nagios is.
Thanks,
John