Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I know the sms gateway for my cell phone provider so I can just send an email to it.

I am looking for examples of entries in contacts.cfg and commands.cfg that are mobile specific.

share|improve this question

4 Answers 4

up vote 2 down vote accepted

on contacts_nagios2.cfg

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 user
        }
define contact{
        contact_name                    name
        alias                           name
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-by-sms
        host_notification_commands      host-notify-by-sms
        email                           mail
        pager                          MOBILENUMBER
        }

And on commands.cfg

define command{
        command_name notify-by-sms
        command_line script-to-sms-service
}
define command{
            command_name host-notify-by-sms
            command_line script-to-sms-service
    }
share|improve this answer
    
How would I be able to limit the texts to 160 characters? Is there any standard way of doing that? –  ckliborn Jan 26 '12 at 23:18
    
You can either impose that limit through your script (trim) or check that your plug-ins never produce more than 160 characters. –  user Jan 27 '12 at 9:57

Using a 3rd-party SMS service, or (even better) using a GSM device as Craig suggests, is going to be much more reliable/robust.

If you're dead set on using the provider's email->SMS gateway, you can use slimmed-down contact commands like this:

define command {
    command_name    notify-host-by-sms
    command_line    /usr/bin/printf "%b" "$NOTIFICATIONTYPE$\n$HOSTNAME$ is $HOSTSTATE$\n$HOSTOUTPUT$\n" | /usr/bin/mail -s "[Nagios] ($HOSTNAME$ $HOSTSTATE$)" $CONTACTEMAIL$

}

define command {
    command_name    notify-service-by-sms
    command_line    /usr/bin/printf "%b" "$NOTIFICATIONTYPE$\n$SERVICEDESC$ ($HOSTNAME$) is $SERVICESTATE$\n$SERVICEOUTPUT$" | /usr/bin/mail -s "[Nagios] ($HOSTNAME$/$SERVICEDESC$)" $CONTACTEMAIL$

If any of these end up being too long, you can remove or substitute different macros in several places, as necessary. See the macro list for info on what's available in a notification command.

share|improve this answer

The first answer will do what you need.

You can send SMS messages through an SMS service, send them via the cell providers email to SMS addresses, or use a local SMS server. We did the latter. This link will give you details on how to do it:

http://www.linuxjournal.com/magazine/using-sms-server-provide-robust-alerting-service-nagios

This has been running for 1.5 yrs. Very reliable, and not dependent on email servers, or third party services.

share|improve this answer

If you want something that can be used out-of-the-box, you can take a look at SMSEagle

That's a hardware sms gateway. Their advantage is that the device stands close to your infrastructure, so when your Internet connection fails you can still send your SMS alerts.

They have ready plugin for Nagios - integration takes about 5min.

share|improve this answer
    
All of your answers, so far, link this same product. I should hope you're not here only to promote it. Please see the section labeled How not to be a spammer from the site help. –  jscott May 29 at 9:34

protected by Michael Hampton Apr 6 '14 at 20:25

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.