Home » Linux » Applications » Nagios Notification By Phone Call

Phone call as Nagios notification

smalllogo7nagiosSome 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 https://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
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):

--registrar sip::5060
--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.

Photo of author
My name is Stefan, I'm the admin of LinuxScrew. I am a full-time Linux/Unix sysadmin, a hobby Python programmer, and a part-time blogger. I post useful guides, tips, and tutorials on common Linux and Programming issues. Feel free to reach out in the comment section.

3 thoughts on “Phone call as Nagios notification”

  1. Cool, but what does the phone call say? I can understand email/sms/IM but what do you hear when you pick up the phone?

  2. We have a working implementation of asterisk in our environment that I’ve tried to leverage to make phone calls for critical service failure alerts. Unfortunately I haven’t been able to have NAGIOS make the calls, though I’ve been able to successfully place the calls by manually entering the following line in the shell prompt:

    /usr/bin/pjsua –config-file=/etc/pjsuarc sip:@

    In addition to the steps provided by you, I’ve done the following:

    -> defined host directive in templates.cfg
    -> defined service directive in templates.cfg
    -> defined contact and contact group directives in contacts.cfg
    -> defined the host/service configurations to use the host/service templates created before

    Am I missing anything?


Leave a Comment