Running shell scripts from nagios commands

Greg Vickers greg_vickers at mbox.com.au
Thu Dec 19 07:25:38 CET 2002


Hi all,

Has anyone here created a shell script and successfully passed arguments
to it from a Nagios command definition? I can't seem to get *any* shell
script to execute from a Nagios command definition :(

Here is the command definition and script:

define command{
   command_name service-notify-by-pager
   command_line /usr/local/bin/create_pager_message $CONTACTPAGER$
"$SERVICEDESC$ on host $HOSTNAME$ is in a $SERVICESTATE$ state"
   }


#!/bin/bash

#This script created 10/12/2002 for use with Nagios
#
#It crafts a message and places that message onto the ITS pager server
#QUT usernames have to be set up on that server, contact xxx
#on xxxxx for configuration

#Create unique filename
FILE=sms.$(date -I).$$
#NOTE: TEMP location requires / appended to dir location!
TEMP=/tmp/
LOGFILE=/var/log/nagios/smbclient_connections.log

#check for args
if [ "$#" -ne 2 ]; then
   echo -e "Usage: $0 <QUT username> <message text>\n\
e.g. create_pager_message username \"Hello this is a message\"" >> $LOGFILE
exit 0
fi

echo "To: $1" > $TEMP$FILE
echo "From: TALSS_Nagios" >> $TEMP$FILE
echo "Message: $2" >> $TEMP$FILE

date '+%b %e %T' >> $LOGFILE
smbclient //server/sms_pager password -U account-c "lcd $TEMP;put
$FILE;exit" >> $LOGFILE

rm $TEMP$FILE


I've tried replacing this script with one that simply echos a line to
/tmp/message.txt and it doesn't work either!

Does anyone have any suggestions?

Thanks,
Greg


---------------------------------------------------------------------
NEW to mBox, receive faxes to any email address!
Find out more http://www.mbox.com.au/fax


-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/




More information about the Users mailing list