Send push notifications from Naemon or Nagios using Pushover

[ Update ]

Last couple of months i’ve been using Naemon as an replacement for Nagios. This post is still valid and works just as well for Naemon. However i choose to follow the developers taking Nagios 3 to Nagios 4 with their new project at www.naemon.org when they where kicked out from the Nagios core-team for political reasons. They are doing a great job so take a look at their project and ideas and give it a spin!

[ /Update ]

So i’ve start using another push-service lately as i’ve been experiencing latency in Prowl when loading notifications. I use push for other things as well other than Nagios notifications such as weather-forecasts every morning, downloads, wordpress notifications, backup-jobs etc etc.

Pushover is more or less equal to Prowl in terms of features and plugins available for download but one thing it can do which Prowl cannot is to set icons/logos on an application and this makes the list-view nice and clear.

To set this up you first have to install the app on your iPhone or Android phone and register an account with pushover.net.

Then register your device and create a “Application” on their site. A application is just a way to tell which application is notifying basically and to set your own logos to the alarms etc. You’ll need 2 API keys, one Application key and the User key.

Download the Pushover notification plugin written by Jedda Wignall from github.

I modified the plugin slightly to include the device-parameter when calling the API as i like to send different notifications to different devices using the same user API key. Let me know if anyone is interested in those changes and i’ll publish them (very simple addition to the script)

Next create a new contact in Nagios that will receive the push notifications:

define contact{
        contact_name                    christian-pushover
        alias                           christian pushover notifications
        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-pushover
        host_notification_commands      notify-host-by-pushover
        _pushover_userkey               qyR<YOURUSERKEY>iJCU
        _pushover_appkey                1My<YOURAPPKEY>Lm87
        _pushover_device                christian-iphone
        }

And add the necessary notification commands:

define command{
       command_name notify-host-by-pushover
       command_line /usr/local/bin/notify_by_pushover.sh -u "$_CONTACTPUSHOVER_USERKEY$" -a "$_CONTACTPUSHOVER_APPKEY$" -s "spacealarm" -t "$HOSTNAME$ is $HOSTSTATE$" -m "Status: $HOSTOUTPUT$"
       }
define command{
       command_name notify-service-by-pushover
       command_line /usr/local/bin/notify_by_pushover.sh -u "$_CONTACTPUSHOVER_USERKEY$" -a "$_CONTACTPUSHOVER_APPKEY$" -s "spacealarm" -t "$SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$" -m "Status: $SERVICEOUTPUT$"
       }

And you’ll need to add your new contact to your hosts and services or contact-group to start getting the push-notifications to your phone.

/Christian

10 thoughts on “Send push notifications from Naemon or Nagios using Pushover”

    1. Only use your own key and nothing from the example above.. If you have issues try running from command line first to ensure you have correct api key etc
      Christian

  1. Download the Pushover notification plugin written by Jedda Wignall from github.
    Well, and now? Where should I put that piece of text?

    1. If you are using the commands above it expects the notification script in /usr/local/bin/ and make sure you have execution flag set on the script “chmod +x /usr/local/bin/notify_by_pushover.sh”

    1. Hi,

      Haven’t tested that one but the script support the -p (Priority) flag so the command would look something like this insted:

      command_line /usr/local/bin/notify_by_pushover.sh -u “$_CONTACTPUSHOVER_USERKEY$” -a “$_CONTACTPUSHOVER_APPKEY$” -p 2 -s “spacealarm” -t “$SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$” -m “Status: $SERVICEOUTPUT$”

      According to the pushover docs prio 2 would require an action from the user when a message is received, prio 1 to bypass quiet hours.

      Let me know how it works out for you!

    2. Not working, tried this before. Priority requires extra parameters, not available in the scrip.
      No warning at all when using -p 2

  2. Not working, tried this before. Priority requires extra parameters, not available in the scrip.
    No warning at all when using -p 2

Leave a Reply

Your email address will not be published. Required fields are marked *