Yesterday I spent the day setting up SMS paging from Nagios. In the past I had just used email to SMS gateways for sending notifications to my cell. SMS Gateways rely on the Nagios host having access to them and the network infrastructure in between them to be functional. Unfortunately many of the times Nagios needs to send out notifications the network is not in a reliable state. I have experienced several instances where a major router/switch goes down and Nagios has no way to let me know. Solution: SMS TAP dial-up gateway.
Most cellular service providers provide dial up SMS TAP gateways (Some even offer toll free numbers). These gateways allow you to send SMS messages to cellular devices by using your modem. With this setup Nagios could be completely disconnected from an IP network and still be able to get notifications sent out via a modem and some paging software.
Here is a great source of TAP dial-up numbers for most providers.
http://www.notepage.net/tap-phone-numbers-c.htm
Before you can configure Nagios to use a SMS TAP gateway you need to install some software that actually makes the call and speaks TAP. I decided to use quickpage (http://www.qpage.org/) because it was small, easy to build, and easy to configure. Just download quickpage, untar, run configure followed by a make and make install. (You may also want to take a look at sendmpage. http://www.sendpage.org)
Quickpage operates in a client server manner. A daemon sits and listens for a quickpage client to connect and tell it to send a message. (The qpage binary is both the daemon and cleint depending on which switches are specified.) Before you can start the qpage daemon you need to create an initial configuration file for quickpage. The configuration file sets some of the following options: Which serial port you modem is on, cellular service provider definitions, and recipient pager definitions. You can place the config file in any directory as long as you use the -C switch to tell qpage where it is. I think the default place it will look is /etc/qpage.cf
Here is an example qpage.cf file:
——————————————————————–
#Administrators email
administrator=protect.the@innocent.com
#Make sure qpage can write to this directory. If you start qpage as root
#it will become the daemon account.
queuedir=/var/spool/qpage
identtimeout=5
snpptimeout=60
#Serial port your modem is on
modem=ttya device=/dev/ttyS0
#A service definition called default
service=default
device=ttya
baudrate=1200
parity=even
allowpid=yes
maxtries=6
phone=18886561727
#A service definition called cingular - This seems to work for cingular cell phones
service=cingular
device=ttya
baudrate=1200
parity=even
allowpid=yes
maxtries=6
phone=18668837243
#A service definition called CingularBB - Blackberries
service=cingularBB
device=ttya
baudrate=9600
parity=even
allowpid=yes
maxtries=6
phone=18009094602
#These are pager definitions, Obviously you should replace 5555551212
#with your own cellular number.
#The service tag associates the pager with the services defined above.
pager=eric
pagerid=5555551212
service=default
pager=EdCingular
pagerid=5555551212
service=cingular
pager=EricCingular
pagerid=5555551212
service=cingularBB
——————————————————————–
Save this file somewhere and then execute the following command to start quickpage:
qpage -C /usr/local/etc/qpage.cf -q 5
The will start quickpage and tell it check the queue every five seconds. You may also want to consider adding the -d switch. This will force qpage into debug mode and is very helpful when testing new configurations.
Also note, that some providers like to have a 1 in front of the area code on the pager ID. This was the case with the Cingular dial-up. i.e. 15555551212 instead of 5555551212. They key here is to play around.
Once qpage is running try to send yourself a test SMS message. Quickpage by default will attempt to connect to the qpage daemon running on localhost. This is fine because we are testing from the same machine.
Type: qpage -p eric
Where eric is the name of the pager definition in your qpage.cf. qpage will connect to the daemon and submit a message for delivery. Now watch your qpage debug output. You should see it attempting to dial-out using the modem and connect to the provider. Thats it!
Because quckpage is a client server applications you can actualy run qpage from any host that has IP access to the machine running the qpage daemon. Just use the -s switch and specify the hostname. When thinking about this options it’s important to remember why we are doing this in the firstplace…
Now configure nagios to use qpage:
First you need to define a notification command. I have the following in my misccommands.cfg file:
# notify via sms using qpage
define command{
command_name notify-by-sms
command_line /usr/local/bin/qpage -s localhost -P $CONTACTNAME$ -f $HOSTNAME$ $SERVICEDESC$ ‘$SERVICEOUTPUT$’ $HOSTNAME$
}
Now define a contact that uses the notify-by-sms notification command:
define contact{
contact_name EricCingular
alias Eric’s Blackberry
service_notification_period 24×7
host_notification_period 24×7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-sms
host_notification_commands notify-by-sms
email top.secret@neutronstar.com
}
Now any service or host that is setup to send notifications to EricCingular will use the notify-by-sms command which calls qpage.
Thats it!