Page 1 of 1

New plugin produces (null) output

Posted: Thu Apr 07, 2011 2:19 am
by Inspector_Gadget
I have a new installation of FAN (Fully Automated Nagios) and I have created a small shell script to check the latency between two hosts in a remote network. The script is located in /usr/lib/nagios/plugins and looks like this:

Code: Select all

#!/bin/bash
ssh root@remote_server ping -c 1 $1 | awk '{ print $7 }'| grep -i time > tmp_latency
cat tmp_latency | while read line
do
        echo ${line:5}
done
exit 0
also, under /etc/nagios/objects/command.cfg I have the following entry

Code: Select all

define command{
        name            check_lat
        command_name    check_lat
        command_line    /usr/lib/nagios/plugins/check_lat.sh -H $HOSTADDRESS$
        }
and in /etc/nagios/objects/servers.cfg

Code: Select all

define service{
        use                     generic-service
        host_name               switch4.domain.com,switch7.domain.com
        service_description     Latency
        check_command           check_lat
        normal_check_interval   5
        retry_check_interval    1
        }
I would expect this to give me the latency between remote_server and the switches, but only returns (null) on the web interface. Am I doing something very stupid that I have not noticed?

Regards,

Inspector Gadget

Re: New plugin produces (null) output

Posted: Thu Apr 07, 2011 11:22 am
by tonyyarusso
  1. Is /usr/lib/nagios/plugins/check_lat.sh excecutable by the nagios user?
  2. Is the nagios user's public key in root@remote_server's authorized_keys?
  3. Are you sure you mean '{ print $7 }'? (On my system it's $8)

Re: New plugin produces (null) output

Posted: Thu Apr 07, 2011 5:49 pm
by Inspector_Gadget
Tony,

Thanks for the fast answer, the script is executable by everyone, I have dropped a RSA key on the right location and the script works OK if I run it manually. I have checked $7 and it is correct. In some machines will not work as could be $8, depending of what version of the OS are you using, but as I said, I tested it manually and gives me a correct answer.

Regards,

Inspector Gadget