SMS notification commands
Nick Pratley
nickpratley1984 at gmail.com
Fri Nov 30 04:20:18 CET 2007
Hi, I need to be able to send notifications via SMS in the event that the
email servers are unavailable, or the internet connection is down. There is
a server on the same network as the Nagios host that has a modem installed
and uses SMS Tools 3 to send messages. To send a message all I need to do is
place a file in a certain directory on that server, in a simple format, and
it does the rest.
So, I created a script called 'notify-by-sms' in /usr/local/nagios/libexec
which is as follows:
TMPFILE=`/bin/mktemp notify.XXXXXX`
/bin/echo -e $1 > $TMPFILE
/usr/bin/scp $TMPFILE sms-server:/var/spool/sms/outgoing/
rm $TMPFILE
The script is owned by the user nagios and is executable. To run it I just
need to pass it a string like "To: <phonenumber>\n\n<messagebody>" as the
only parameter. If I run it from the command line while logged in as nagios
it works fine.
I have the following in commands.cfg which I adapted from
notify-service-by-email and notify-host-by-email:
# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line /usr/local/nagios/libexec/notify-by-sms "To:
$CONTACTPAGER$\n\n***** Nagios *****\n\nNotification Type:
$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: HOSTSTATE$\nAddress:
$HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
}
# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /usr/local/nagios/libexec/notify-by-sms "To:
$CONTACTPAGER$\n\n***** Nagios *****\n\nNotification Type:
$NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: HOSTALIAS$\nAddress:
$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:
$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"
}
I see the following in /usr/local/nagios/var/nagios.log, as an example (I
have replaced some things with <...>):
[1196327641] SERVICE NOTIFICATION:
<contactname>;<servername>;SyncServer;CRITICAL;notify-service-by-sms;CRITICA
L - Error Fetching http://<ipaddress>/sync/ds [503] Service Temporarily
Unavailable
however the sms is not received. It does not even appear in the log on the
SMS server which indicates the script isn't running or isn't able to scp the
file to that server. I am using public key authentication to negate the need
for a SSH password to be entered.
Any ideas what the problem could be, when it runs manually from the command
line but not through the nagios daemon?
Thank you,
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20071130/d69c89e3/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
-------------- next part --------------
_______________________________________________
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