check_ssh_off

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
MSsupport
Posts: 14
Joined: Sat Jun 15, 2013 7:20 am

check_ssh_off

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_ssh_off

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
MSsupport
Posts: 14
Joined: Sat Jun 15, 2013 7:20 am

Re: check_ssh_off

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_ssh_off

Post by abrist »

No problem, happy scanning and scripting!
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked