I use Nagios a lot. If it’s not for the peace of mind that I know that my, and my clients infrastructure is monitored, its for the obsessive compulsiveness of the statistics. Admittedly, stats-wise I use Munin now, however, for monitoring everything I use Nagios.
One of the awesome things about Nagios is how you can configure it to do various things when an alert is triggered. For me, speed is the key, and with Textlocal’s API, I can get an alert to me within 4 seconds of an issue occurring.
To configure this, we need to set up some commands. The following needs to be added to your Nagios config file which contains commands (for me, it’s called commands.cfg):
command_line wget "http://api.txtlocal.com/send/?apikey=<<APIKEY>>&sender=Nagios&numbers=$CONTACTPAGER$&message=$NOTIFICATIONTYPE$%25nHost: $HOSTNAME$ is $HOSTSTATE$%25nTime: $LONGDATETIME$%25n%25n$HOSTOUTPUT$"
command_line wget "http://api.txtlocal.com/send/?apikey=<<APIKEY>>&sender=Nagios&numbers=$CONTACTPAGER$&message=$NOTIFICATIONTYPE$%25nService: $SERVICEDESC$ on $HOSTALIAS$%25nState: $SERVICESTATE$%25nTime: $LONGDATETIME$%25n%25n$SERVICEOUTPUT$"
<<APIKEY>> with an API key generated within Textlocal’s Settings->API Key.
Next, you need to set some additional bits up on the users - you need to specify a contact number and also to tell Nagios to use these new functions for alerts. To do this:
service_notification_commands add the option
service_notify_with_sms (space separated)
host_notification_commands add the option
host_notify_with_sms (space separated)
3) Add a
pager definition which contains the mobile number - e.g.
Restart Nagios, and job’s done!