DAPNET Alarm Page by NAGIOS

After settinp up a DAPNET client for the POCSAG Amateur Radio paging network I was looking for some good source for interesting information to be sent to my pager. I already had a Nagios monitoring solution set up in order to monitor several D-Star service and repeaters in my area. So I wanted to get Nagios to inform me as soon as one of these services changes state to critical.

Alert showing POCSAG transmitter down
Alert showing POCSAG transmitter down

The solution is to implement a second method for nagios to send a notification. The original method to send an alarm via email was left as it is.

In order to accomplish this you need to define a notification command. On my Ubuntu 14.04.2 system it is defined in /etc/nagios3/command.cfg. I added:

define command{
   command_name   notify-service-by-funkruf
   command_line   usr/bin/printf "**NAGIOS** $NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" | /usr/local/bin/nagios-funkruf.sh
}

The actual script that does send out the alarm is /usr/local/bin/nagios-funkruf.sh:

#!/bin/bash
USER=df2et
PASS=puttyourpassinhere
URL=http://www.hampager.de:8080
RECIPIENT=DF2ET
TEXT=$(cat -)

curl -s -H "Content-Type: application/json" -X POST -u $USER:$PASS -d "{ \"text\": \"$TEXT\", \"callSignNames\": [\"$RECIPIENT\"], \"transmitterGroupNames\": [\"test_N18\"], \"emergency\": false }" $URL/calls 2>&1 > /dev/null

exit 0

In order to use that script I defined a new contact in /etc/nagios3/conf.d/contacts_nagios2.cfg:

define contact{
        contact_name                    df2et
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-funkruf
        host_notification_commands      notify-service-by-email
}

This contact is then added to a group named DF2ET (further down the same file):

define contactgroup{
        contactgroup_name       DF2ET
        alias                   Funkruf Alarmierung
        members                 df2et
}

The contact group “DF2ET” and thus the contact “df2et” gets informed via page and via email. This contact group can be used while defining services by just adding it to the contact_groups. For example:

define service {
   [...]
   contact_groups             admins, DF2ET
   [...]
}

That should make you end up with alarm calls via hampager.de and the DAPNET master run by RWTH Aachen.