Tweak - Nagios SMS Messaging

Want to send SMS messages from Nagios?  SMS messages sometimes blocked when sending them via <phone#>@provider.com?  Sending alot of SMS messages?  Sounds like you need an SMS Gateway Provider.

In our corporate environment we wanted a more reliable/consistant SMS messaging system to work with our Nagios monitoring environment.   A little research quickly led us to Clickatell.  To keep things as simple as possible, we setup Nagios to use the SMS Gateway via SMTP API.

Now we had to configure Nagios.  First off, we needed to create a notification method/command.  Here is the command.cfg entry we created:

define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%b" "api_id:<API_ID> \nuser:<USERNAME> \npassword:<PASSWORD> \nto:$CONTACTPAGER$\nreply:<REPLY_ADDY> \ntext:$NOTIFICATIONTYPE$ $HOSTALIAS$-$SERVICEDESC$ $SERVICESTATE$\ntext:Address-$HOSTADDRESS$\ntext:Additional Info-$SERVICEOUTPUT$" | /bin/mail -s "$HOSTALIAS$-$SERVICEDESC$ is $SERVICESTATE$" $CONTACTEMAIL$
        }

Bold items in brackets you must specify based on your environment.  Notice how we had to significantly strip down the info sent via SMS text message.  We found the above was simple and communicated the required info. 

Then let's create a contact to use...

define contact {
        contact_name    sms
        use             generic-contact
        alias           SMS Alert
        email           sms@messaging.clickatell.com
        pager           16665551234,16665554321
        service_notification_commands   notify-service-by-sms
}

The phone numbers to SMS are just a comma seperated list.  It is important to note the phone numbers must have a "1" before them.

Now simply add the "sms" contact in the service definitions you want to alert by SMS text messages.    Reload Nagios and you should be off and running.