Using shell script in command definition

Greg Vickers greg_vickers at mbox.com.au
Tue Dec 10 09:34:12 CET 2002


Hi all,

I was wondering if anyone has used a (bash) shell script in one of their
command definitions? My script just doesn't run from within my command
definition:

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


The script create_pager_message:


#!/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 Blah blah
#on x0000 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 1 ]; then
   echo -e "Usage: $0 <QUT username>\nScript expects the message text \
from stdio, e.g. echo \"This is a message.\" | create_pager_message"
exit 0
fi

echo "To: $1" > $TEMP$FILE
echo "From: TALSS_Nagios" >> $TEMP$FILE
echo -n "Message: " >> $TEMP$FILE
cat 3<&0 >> $TEMP$FILE

#Send $FILE to the sbm share on raven. There are currently two accounts
#available to TALSS/SSS, sms002 & sms003. See 'Installing Nagios.doc' for
#details.

date '+%b %e %T' >> $LOGFILE
smbclient //raven/sms_pager PASSWORD -U sms002 -c "lcd $TEMP;put
$FILE;exit" >> $LOGFILE

rm $TEMP$FILE



As you can see, i'm not a fantastic script programmer! Has anyone got a
bash shell script to run from within a command defintion?

Thanks,
Greg Vickers

p.s. on a side note, my email from my regular email address isn't being
allowed through to the sourceforge mail server! Anyone know who I
contact to ask why this is so?


---------------------------------------------------------------------
Would you like to receive faxes to your personal email address?
You can with mBox.  Visit http://www.mbox.com.au/fax


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf




More information about the Users mailing list