New plugin produces (null) output

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
Inspector_Gadget
Posts: 2
Joined: Thu Apr 07, 2011 1:33 am
Location: Milky Way, half way between Perseus and Sagittarius, third rock from the Sun

New plugin produces (null) output

Post 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
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: New plugin produces (null) output

Post 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)
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
Inspector_Gadget
Posts: 2
Joined: Thu Apr 07, 2011 1:33 am
Location: Milky Way, half way between Perseus and Sagittarius, third rock from the Sun

Re: New plugin produces (null) output

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