Setting up nagios3 to send prowl notifications
Updated 27.i.2010 to reflect mig5's corrections
I spent a few minutes today setting up our nagios install at work to page me via prowl, instead of an email->sms gateway. Why? Because I'm cheap, that's why - don't like paying for any more texts than I must. I ran into a few gotchas, so I thought I would briefly document the process. First, you must download the perl script that will send prowl notifications.
Next, you will have to install the Crypt::SSLeay and LWP::UserAgent library for perl, so it can access https URLs.
Now, try it out to be sure it works:
You should get a 'Notification successfully posted.' message. (and a popup on your phone, of course!) If the script isn't working, you'll have to figure out the reason, because nagios depends on it.
Once you've ironed all that out, it's time to configure nagios!
First, you need to set up your contact information. Edit whichever file you keep your contacts in, and modify an existing record, or add a new one, similar to this:
It is very important that you leave the underscore in front of the _prowl_apikey variable, as Nagios' custom variables depend on it.
Next, you'll need to add the custom prowl notification commands. Edit the appropriate file, and add these commands:
If your perl binary doesn't live in /usr/bin, be sure to give the correct path. (run 'which perl' to find this out if you don't know) If you try to run the prowl.pl script directly, (without using the system perl binary) nagios uses its own perl interpreter, and you'll get an error similar to this in the nagios logs:
If you have any trouble, check the nagios debug logs, (you may need to turn up the nagios debug level) and try to run the command it's producing as the nagios user.
I spent a few minutes today setting up our nagios install at work to page me via prowl, instead of an email->sms gateway. Why? Because I'm cheap, that's why - don't like paying for any more texts than I must. I ran into a few gotchas, so I thought I would briefly document the process. First, you must download the perl script that will send prowl notifications.
- sudo mkdir -p /usr/local/bin
- sudo wget -O /usr/local/bin/prowl.pl http://prowl.weks.net/static/prowl.pl
- sudo chmod +x /usr/local/bin/prowl.pl
- # If you're running debian/ubuntu
- sudo apt-get update; sudo apt-get install libcrypt-ssleay-perl liblwp-useragent-determined-perl
- # otherwise find a package for your distro, or run:
- # sudo cpan install Crypt::SSLeay
- # sudo cpan install LWP::UserAgent
- /usr/local/bin/prowl.pl -apikey='yourAPIkeyHere' -application='prowl.pl' -event='test' -notification='mic check 1 2'
- define contact{
- contact_name adrian_pager
- alias Adrian Rollett
- service_notification_period 24x7
- host_notification_period 24x7
- service_notification_options w,u,c,r
- host_notification_options d,u,r
- service_notification_commands notify-service-by-prowl
- host_notification_commands notify-host-by-prowl
- _prowl_apikey yourAPIkeyGoesHere
- }
- define command{
- command_name notify-host-by-prowl
- command_line /usr/bin/perl -w /usr/local/bin/prowl.pl -apikey="$_CONTACTPROWL_APIKEY$" -priority=1 -application="Nagios" -event="Host" -notification="$HOSTNAME$ $HOSTDESC$ '$HOSTOUTPUT$'"
- }
- define command{
- command_name notify-service-by-prowl
- command_line /usr/bin/perl -w /usr/local/bin/prowl.pl -apikey="$_CONTACTPROWL_APIKEY$" -priority=1 -application="Nagios" -event="Service" -notification="$HOSTNAME$ $SERVICEDESC$ '$SERVICEOUTPUT$'"
- }
- *ePN failed to compile /usr/local/bin/prowl.pl: "Missing right curly or square bracket at (eval 1) line 95, at end of line syntax error at (eval 1) line 102, at EOF"
Prowl question
I recently installed the notify by prowl code.
I can get the test message through the linux console but, when i run it through nagios it does not work. any ideas?
Here is the command verbage.
# 'notify-host-by-prowl' command definition
define command{
command_name notify-host-by-prowl
command_line /usr/bin/perl -w /usr/local/bin/prowl.pl -apikey="$_CONTACTPROWL_APIKEY$" -priority=1 -application="Nagios" -event="Host" -notification="$HOSTNAME$ $HOSTDESC$ '$HOSTOUTPUT$'"
}
# 'notify-service-by-prowl' command definition
define command{
command_name notify-service-by-prowl
command_line /usr/bin/perl -w /usr/local/bin/prowl.pl -apikey="$_CONTACTPROWL_APIKEY$" -priority=1 -application="Nagios" -event="Service" -notification="$HOSTNAME$ $SERVICEDESC$ '$SERVICEOUTPUT$'"
}
Thanks in advance.
Prowl
Just a quick note...
I wanted to let you know this guide helped me a bunch when setting up Nagios to prowl. I was linked here from iNag (which is also an awesome app!)
Thanks for sharing!
Rob
great!
glad to hear it...
Needed
Hi Adrian,
Just in the middle of setting up the same thing. Thanks for your excellent guide.
Just thought I'd note that if you're on Debian/Ubuntu, you'll also need to apt-get install liblwp-useragent-determined-perl if you haven't got it already, or else Perl will die with this error:
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /usr/local/bin/prowl.pl line 33.
BEGIN failed--compilation aborted at /usr/local/bin/prowl.pl line 33.
Oops, two other things :)
Sorry, just nitpicking..
Your host command definition in the example is using $SERVICEDESC$ '$SERVICEOUTPUT$' instead of $HOSTDESC$ $HOSTOUTPUT$, these would result in empty variables in the prowl message.
Also the path to your prowl.pl in the command definitions is /usr/local/nagios3/libexec, but previously we wget it to /usr/local/bin
Otherwise, great! Thanks again.