Reversing ssh plugin results for notification an going RED

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
JohnFM3
Posts: 6
Joined: Tue Dec 20, 2011 4:19 pm

Reversing ssh plugin results for notification an going RED

Post 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
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Reversing ssh plugin results for notification an going R

Post by jsmurphy »

You definitely have a knack for finding niches that I don't think anyone has filled :lol:. 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
JohnFM3
Posts: 6
Joined: Tue Dec 20, 2011 4:19 pm

Re: Reversing ssh plugin results for notification an going R

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