Page 1 of 1

check_ssh_off

Posted: Sat Jun 15, 2013 7:39 am
by MSsupport
I’m looking for the best (appropriate) way to change how the ‘service state’ is returned (reported) from a service. For example; the SSH service on a virtual host machine is desired to be normally ‘off’; when using the check_comand ‘check_ssh’, it returns “Connection refused” (return code of ‘2’) and its State is reported as ‘CRITICAL’. What is desired is that for a return code of ‘2’ the State is reported as ‘OK’ and for a return code of ‘0’ the State is reported as ‘CRITICAL’.

Considered options for a check_ssh_off service so far: Write a completely new service, use a script to change the return code result from the ‘check_ssh’, or just ignore it :-) .

Your feedback is appreciated.

Re: check_ssh_off

Posted: Mon Jun 17, 2013 11:09 am
by abrist
The check_ssh plugin is limited and does not have an "invert" feature for the check result. You will most likely have to create a script to check the port of the server and if it is open, return a critical:

Code: Select all

#!/bin/bash
STATE=$( nmap localhost | grep ssh | awk '{print $2}' )
case $STATE in
        open )
                echo "Critical! SSH port open and listening"
                exit 2
                ;;
        closed )
                echo "OK - SSH port closed"
                exit 0
                ;;
esac

Re: check_ssh_off

Posted: Wed Jun 19, 2013 6:24 am
by MSsupport
I didn't know about nmap; looks like a very useful tool; I will install and give it a try.

Thanks for the help.

Re: check_ssh_off

Posted: Wed Jun 19, 2013 12:10 pm
by abrist
No problem, happy scanning and scripting!