Running shell scripts from Nagios commands
Potter, G M (Greg)
GPotter at MarathonOil.com
Thu Dec 19 14:41:31 CET 2002
Here is the script I use for pager notification.
The MACRO variables show up for me. Granted I
am not calling a shell script, but the variables
are populated and the paging routing works.
System Specs: Solaris 8, Nagios 1.0
define command{
command_name notify-by-qpage
command_line /bin/echo "okcu06 $HOSTALIAS$/$SERVICESTATE$/$SERVICEDESC$ $OUTPUT$" | /usr/
local/bin/qpage -p $CONTACTPAGER$
}
> -----Original Message-----
> From: Greg Vickers [mailto:greg_vickers at mbox.com.au]
> Sent: Thursday, December 19, 2002 12:26 AM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Running shell scripts from nagios commands
>
>
> 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/
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
>
-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now! Before the Holidays pass you by.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/
More information about the Users
mailing list