Use Amazon SNS for Nagios Alerts

Amazon recently added SMS publishing capability to their Simple Notification Service(SNS) platform. 

Using SNS to send nagios alerts:

At Bitly, we used individual carrier’s email SMS gateways (eg. 123456789@text.att.net) to send pages to the on-call person as well as other people on the ops team. This solution was not cutting it as messages were heavily throttled on the carrier’s side (the gateway being a free service provided by the carrier meant that we couldn’t really complain or get the problem rectified). This basically meant that pages arrived hours later in some cases and defeated the purpose of an alert during an emergency. 

Once SMS capability was announced, it was pretty much a no-brainer to switch to SNS.

I wrote a quick and simple python script with the help of a popular AWS python library called boto. You can find the source over at http://bit.ly/pyamazonsns.

This script can be used to send any kind of SNS message, not just SMS.

Here is a snippet of how this would tie into nagios:


define command{
    command_name  notify-host-by-txt
    command_line  printf "%b" "$HOSTALIAS$" | send_sns.py $CONTACTPAGER$
}

Feel free to fork it, improve on it and add features beyond the scope of our usage. Drop us a line to let us know :)