Debuggin Check-Scripts

Thomas Guettler hv at tbz-pariv.de
Tue Mar 7 16:55:01 CET 2006


Hi,

I had difficulties to debug the check commands.
I wrote a little wrapper script, which logs some
informtion into a logfile. The is usefull if you want
to see how variables (e.g. $USER1$) get expanded and
which command is actually run.

Use it like this. You need absolute path $USER$ gets only
expanded once!

command_line    /usr/local/nagios/libexec/log_checkcommand $USER1$/check_...

Here is the script:

#!/bin/bash
SCRIPT=`basename $0`
LOGFILE=/usr/local/nagios/var/checkcommands.log
if [ ! -w $LOGFILE ]; then
   echo "$SCRIPT: Can not write to $LOGFILE"
   exit 3
fi
echo `date` >> $LOGFILE
echo `id`   >> $LOGFILE
echo $@     >> $LOGFILE

for arg in ${1+"$@"}; do
    echo "arg $arg" >> $LOGFILE
done
echo       >> $LOGFILE
${1+"$@"}


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list