SMS notification commands

mark redding mwjredding at gmail.com
Fri Nov 30 10:05:22 CET 2007


Hi,

A couple of questions for you.

1. When you run this interactively are you doing so from the account
that nagios is running under ? This could be the cause if the ssh key
information is not present for the 'nagios' account.
2. Have you defined the contact name correctly :- for example, I have
the following in my config for my on-call sysadmin.

define contact{
        use                             mark
        contact_name                    oncall
        alias                           On Call Sys Admin
        service_notification_options    c,r
        host_notification_options       d,r
        service_notification_commands   service-notify-by-sms
        host_notification_commands      host-notify-by-sms
}

and :-

define contact{
        name                            mark
        contact_name                    mark
        alias                           Mark Redding
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    c,r
        host_notification_options       d,r
        service_notification_commands   service-notify-by-email
        host_notification_commands      host-notify-by-email,host-notify-by-sms
        email                           mwjredding at gmail.com
        pager                           44????????
}


regards,
Mark

this is in addition to the usual

define contactgroup {
        contactgroup_name       admin
        alias                   System Administrators
        members                 nagaios,mark,fred,oncall
}

On 30/11/2007, Nick Pratley <nickpratley1984 at gmail.com> wrote:
>
>
>
>
> 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;CRITICAL
> - 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
>
>
>
>
> -------------------------------------------------------------------------
> 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
> _______________________________________________
> 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
>


-- 
bright blessings,
Mark

-------------------------------------------------------------------------
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
_______________________________________________
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