Some time ago I found it pretty useful to configure Nagios monitoring system to send me a phone call in case of some critical problem. If some mission critical application goes down at night most probably you’ll miss an e-mail or sms notifying about that but won’t miss a telephone call to your cell phone. Honestly a telephone call is much more notorious rather than IM message notification or, again, e-mail/sms. You’re welcome to see below how to configure your Nagios for that.
First of all you need to have account at some SIP voip service provider like www.voiptalk.org or similar (Skype is not an option so far). Once registered you will get SIP username/password and SIP gateway’s IP address which will be used to make outgoing calls by Nagios.
1. Download and install pjsua console caller from pjsip.
cd /usr/src/ wget http://www.pjsip.org/release/1.10/pjproject-1.10.tar.bz2 tar -xvjf pjproject-1.10.tar.bz2 cd /usr/src/pjproject-1.10 ./configure --disable-sound make sudo cp pjsip-apps/bin/pjsua-i686-pc-linux-gnu /usr/bin/pjsua
2. Configure pjsua.
Create /etc/pjsuarc configuration file with the following contents (depends on details provided by SIP provider):
--null-audio --registrar sip::5060 --realm=* --id sip:<username>@<SIP gateway IP>:5060 --username <username> --password <password>
From that point you can try calling yourself by command:
/usr/bin/pjsua --config-file=/etc/pjsuarc sip:<your phone number>@<SIP gateway IP>
3. Configure Nagios to notify you by sending you a telephone call:
Add the following block to Nagios’ commands.cfg:
define command{ command_name notify-host-by-sip command_line (sleep 30 && echo q) | /usr/bin/pjsua --config-file=/etc/pjsuarc sip:$CONTACTEMAIL$ }
Add below contact to Nagios’ contact.cfg:
define contact{ contact_name user_sip alias useralias service_notification_period 24x7 host_notification_period 24x7 service_notification_options c host_notification_options d service_notification_commands notify-service-by-sip host_notification_commands notify-host-by-sip email <your phone number>@<SIP gateway IP> }
That’s it, from this point Nagios will call you in case of critical problem and won’t bother you with warnings.