SMS script...

Christiaan Ehlers Christiaan.Ehlers at inclarity.co.uk
Tue Feb 17 17:33:28 CET 2004


Hi

Our sms server can not take more than 160 characters in the body of the text
message.  I then wrote a script to help cut down those notifications that
are larger than 160 characters.  (the script is pretty shabby, please feel
free to sugest improvements)  Now when I run the script manualy, I get a
txt.  But it would seem when I empliment the script in nagios (see the
misccommand.cfg extract) I don't seem to get any messages.

I have the following command in misccommand.cfg

define command{
        command_name    service-notify-cleansms
        command_line    /bin/echo "$SERVICESTATE$ alert for
$HOSTALIAS$/$SERVICEDESC$ $OUTPUT$" > /home/scripts/msg && /home/scripts
/sms.sh $CONTACTEMAIL$
        }

And the sms.sh script is as follow... Deletes one character after the other,
starting at the back, untill it has 160.

noclobber=0
FILE=/home/scripts/msg

while [ `wc -m $FILE | awk '{print $1}'` -gt 160 ] 
        do

        if [ `cat $FILE | sed -n '$p' | wc -m`  = 1 ]; then
                cat $FILE | sed '$d' > $FILE
        else
                cat $FILE | sed '$s/.$//' > $FILE
        fi

        done

cat $FILE | mail $1


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
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