[Nagiosplug-help] problem with self written shell scripts

Ronald ronald at ronaldverlaan.com
Wed Jul 23 13:28:56 CEST 2008


Dear list,

I am in the process of migrating from netsaint to nagios. I made some 
simple shell scripts in the past that worked fine in netsaint but has 
problems in nagios. Since I think the cause will be the same for all
I will describe only one of those:

This is what the script called check_snapvault_appl looks like:

-------------- BEGIN ----------------------

#!/usr/bin/bash
# netsaint plugin that checks how many hours it has been since the last 
snapvault backup
#
# Author Ronald Verlaan
#
SNAPVAULT=nl-dhg-r200-01:/vol/unix_backup/appl_backup
warn=75
crit=100

hours=`rsh -l netsaint:netsa1nt 10.55.76.36 snapvault status | grep 
$SNAPVAULT | sed 's/:/ /g' | awk '{ print $6 }'`

answer="Snapvault backup $SNAPVAULT has been $hours hours!"

if [ $hours -ge $crit ]
then
state=2
elif [ $hours -lt $warn ]
then
state=0
elif [ $hours -lt $crit ]
then
state=1
else
state=-1
fi

echo $answer
exit $state

--------------- END ----------------

When I run the script manually the output is this:

Snapvault backup nl-dhg-r200-01:/vol/unix_backup/appl_backup has been 14 
hours!

However within nagios the output is:

Snapvault backup nl-dhg-r200-01:/vol/unix_backup/appl_backup has been hours!

As a result (I suppose) the state is unknown.

In other words it looks like the command:
rsh -l netsaint:netsa1nt 10.55.76.36 snapvault status | grep
$SNAPVAULT | sed 's/:/ /g' | awk '{ print $6 }'

does not work.


But again when I run this manually it does give me the proper 
output.

Any idea what is going on here or how to troubleshoot this?

I am struggling with this fo a week now but I am clueless :-(

Best regards,

--
Ronald Verlaan
ronald at ronaldverlaan.com




More information about the Help mailing list