I am having an issue creating my 1st passive check for Nagios Core and can't figure out the disconnect. I am running a distributed environment with Linux and have a need to check space on a partition from a legacy server.
if I run the test manually from the command line on the remote distributed server, I get the expected response :
nagios@str7924sa:/usr/local/nagios/libexec> ./check_starlite_size str7924 70 90
[1287604790] PROCESS_SERVICE_CHECK_RESULT;str7924;2;Critical. Free Space: 2 % available
On my central server, in nagios.log I am getting the following :
PASSIVE SERVICE CHECK: str7924sa;Starlite Size;3;(null)
Now, I do not have the legacy server ( str7924 ) listed as a host in the hosts.cfg file as I didn't think I had to.
Tried running the script with the echo command redirected to the nagios.cmd file and without with no success.
Can anyone tell me what I am missing here? Our environment will need to use alot of passive checks from existing 3rd party scripts.
libexec script
Code: Select all
#!/bin/bash
#
# Plugin to check free disk space for starlite
# using rsh
#
# Command-Line for service (example)
#
##########################################################
CLOCK=`date +%s`
HOST=$1
case $1 in
--help | -h )
echo "Usage: check_starlite_size [dev] [warn] [crit]"
echo " [warn] and [crit] as int"
echo " Example: check_starlite_size str7924 70 90"
exit 3
;;
* )
;;
esac
if [ ! "$1" -o ! "$2" -o ! "$3" ]; then
echo "Usage: check_diskfree [dev] [warn] [crit]"
echo " [warn] and [crit] as int"
echo " Example: check_diskfree hda1 70 90"
echo "Unknown: Options missing"
exit 3
fi
used=`sudo /usr/bin/rsh $1 df -v |grep /starlite6 | head -1 | awk '{print $4}'`
free=`sudo /usr/bin/rsh $1 df -v |grep /starlite6 | head -1 | awk '{print $5}'`
full=`echo $(($used+$free))`
percent=`echo $((( $free * 100 ) / $full))`
warn=`echo $((( $full * $2 ) / 100 ))`
crit=`echo $((( $full * $3 ) / 100 ))`
if [ "$warn" -gt "$crit" -o "$warn" -eq "$crit" ]; then
echo "Unknown: [crit] must be larger than [warn]"
exit 3
fi
if [ "$used" -lt "$warn" -o "$used" -eq "$warn" ]; then
OUTPUT="OK. Free Space: $percent % available"
STATUS= 0
elif [ "$used" -gt "$warn" -a "$used" -lt "$crit" ]; then
OUTPUT="Warning. Free Space: $percent % available"
STATUS=1
elif [ "$used" -gt "$crit" ]; then
OUTPUT="Critical. Free Space: $percent % available"
STATUS=2
else
OUTPUT="Unknown"
exit 3
fi
echo "[$CLOCK] PROCESS_SERVICE_CHECK_RESULT;$HOST;$STATUS;$OUTPUT"
#> /usr/local/nagios/var/rw/nagios.cmd
Code: Select all
define service{
use generic-service
host_name str7924sa
# hostgroup_name Store_servers
notification_options w,c
service_description Starlite Size
check_command check_starlite_size!str7924!70!90
}
define command {
command_name check_starlite_size
command_line $USER1$/check_starlite_size -H $HOSTNAME$ -w $ARG1$ -c $ARG2$
}
Steve