Nagios and iPhone push notifications

I have a friend who works for an ISP and a few months back he told me about how he had wrangled Nagios into monitoring their servers and networking equipment. His story piqued my interest, and last night I finally downloaded Nagios, and configured it to monitor my 24×7 Linux host that sits behind my TV providing a number of different services to my internal network. Installing Nagios from source was simple with the instructions at http://www.nagios.org, and within minutes I was up and running. I had a little trouble with setting up auth_digest authentication for apache2 but I think that was mostly because that module wasn’t enabled by default. After I got the main configuration up and running, and I was able to access the web interface, I began to poke around. While I was doing this I got an email notification that my disk space was over 20%. I then thought, wouldn’t this be cool if I could turn this into a push notification?
I already set up a script provided by http://prowl.weks.net/static/prowl.pl, and have that working to notify me when a new TV show is added to my Linux host. I found that the settings for notifications in Nagios were located at /usr/local/nagios/etc/objects/commands.cfg. In the notifications section, I added the following below the two entries for email notifications, which I included:

# ‘notify-host-by-email’ command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /usr/bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$
}

# ‘notify-service-by-email’ command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$” | /usr/bin/mail -s “** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}

# ‘notify-host-by-prowl’ command definition
define command{
command_name notify-host-by-prowl
command_line /usr/local/bin/prowl.pl -application=”Nagios” -event=”** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” -notification=”Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$” -priority=1 -apikey=THISISWHEREMYAPIKEYWOULDGO
}

# ‘notify-service-by-prowl’ command definition
define command{
command_name notify-service-by-prowl
command_line /usr/local/bin/prowl.pl -application=”Nagios” -event=”** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” -notification=”Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$” -priority=1 -apikey=THISISWHEREMYAPIKEYWOULDGO
}

So now, when Nagios sends a notification, I get a pop up instantly on my phone that looks something like this:

Nagios iPhone Prowl
Nagios iPhone Prowl

Righteous!!

Advertisements

Author: jayholler

A technology lover living in California with my wife and two children.

1 thought on “Nagios and iPhone push notifications”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s