Service checks- how to alter


#1

I have finally been able to veiw info when logging into Nagios. Installed via synaptec manager Nagios 3.0.6 on a Ubuntu9.10 server.
All looks good apart from one service check, SSH. Connection is refused, critical. Could this be that I have SSH set up on a a non default port? If so how can I change this? Have looked in the service commands and there is now mention of port numbers in the command string.

I know SSH is OK because I am connected via putty. Its just annoying to see as all is working!

Any ideas?


#2

check services.cfg
your ssh check is defined by a command.
check commands.cfg and see how that commmand is transalted into a plugin command line.
if there isn’t what you need cehck the plugin itself.
in the libexec directory run ./check_ssh --help and see what parameter is availaple fro the port
define a new command in commands.cfg
modify the service definition for the host you need to use the new version of the command you defined.

check the config files are correct (running nagios with the -v option)
reload nagios (DO NOT RESTART!)


#3

Thanks luca, I have checked the service command for ssh and added the port number after the -p entry

In the config it looks like this:

check_ssh /usr/lib/nagios/plugins/check_ssh '$HOSTADDRESS$'
check_ssh_4 /usr/lib/nagios/plugins/check_ssh -4 '$HOSTADDRESS$'
check_ssh_port /usr/lib/nagios/plugins/check_ssh -p xxxxx ‘$ARG1$’ '$HOSTADDRESS$'
check_ssh_port_4 /usr/lib/nagios/plugins/check_ssh -4 -p xxxxx ‘$ARG1$’ ‘$HOSTADDRESS$’

Still getting the connection refused Service critical

Instead of it checking ssh on localhost do I need to specify the actual hostname of the server?


#4

$HOSTADDRESS$ refers to the ip address of the host the service check is associated to, so you don’t need to change that… clearly if the service check is for localhost it wil never work on the remote host…

what are those xxxxx in the description? you should use the args…

calmly try to indesratnd how this works before doing changes. the documents explain it quite well. just take a couple of minutes to understand itr and the rest will be easier :slight_smile:

it’s evn faster than if i try to set it up for you… as nect time you are set to go intsead of depending on somebody else :slight_smile:

Luca


#5

xxxxx = port number (not shown obviously)

Yeah I couldn’t agree more, better to rectify ones self, sticks in the mind then

Will have a read some more in the docs.

Thanks luca


#6

in the command definition you have now:
-p 2022 $ARG1$

using 2022 as an example.

problem is theorically you either define a fixed port:
check_ssh_2022 …] -p 2022 …]

or you use a parameter:
check_ssh_port …] -p $ARG1$ …]

i left out …] all which is irrelevant now.

in the first case it will use port 2022 every time
in the second case you will have to use
check_ssh_port!2022
in the service deiniiton
! indicates an argument being the port number $ARG1$ it has to be the first argument used.

Hope this helps :slight_smile:

Luca


#7

Excellent, thank you very much luca. All green now. Hey its only taken me 3 months to solve that little problem, good job I am paying myself on an hourly rate haha.