I was looking into using Pushbullet to notify me of the Nagios events, instead of sending the notifications via email. I stumbled upon this reddit post by a user named 1lowlyadmin which perfectly describes the process, but is around two years old and still uses the older Pushbullet API.

If you don’t know what Pushbullet is, here is a link to their site. They have clients for Android and iOS mobile devices, for Chrome, Firefox and Opera browsers, and a native client for Windows OS.

Pushbullet docs: https://docs.pushbullet.com/
Get API key: https://www.pushbullet.com/#settings/account – Go to Access Tokens and click Create Access Token.

There are two ways to get IDs for your devices, first is as described in the reddit post with curl:

curl -u : https://api.pushbullet.com/api/devices

The second is to go to https://www.pushbullet.com/#devices and click the device, and the last string in the url is the device ID.

The lines to add to commands.cfg (using the new Pushbullet v2 API):

'notify-host-by-push' command definition - ident define command{ command_name notify-host-by-push command_line /usr/bin/curl --header 'Access-Token: ' --header 'Content-Type: application/json' --data-binary '{"body":"***** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$","title":"** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ ","type":"note","device_iden":""}' --request POST https://api.pushbullet.com/v2/pushes } # 'notify-service-by-push' command definition - ident define command{ command_name notify-service-by-push command_line /usr/bin/curl --header 'Access-Token: ' --header 'Content-Type: application/json' --data-binary '{"body":" $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ","title":"*** Nagios ***** Notification Type: $NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$ ","type":"note","device_iden":""}' --request POST https://api.pushbullet.com/v2/pushes }


with your API Access Token and

with your device ID (iden).

You can also publish this to a Pushbullet channel, so that other people can subscribe to these notifications, such as your coworkers. In that case you have to create a channel and obtain the channel tag, and then replace device_iden with channel_tag. Keep in mind that the APIkey used to push the notifications to a channel needs to be of the channel owner.

Lines to be added to contacts.cfg are the same from the reddit post:

define contact{ contact_name pusher use generic-contact alias Pushbullet Notification service_notification_commands notify-service-by-push host_notification_commands notify-host-by-push }

If you wish to just use pushbullet, you can just replace the email ones in the templates.cfg for the generic-contact, and skip adding a new contact:

define contact{ name generic-contact ; The name of this contact template service_notification_period 24x7 ; service notifications can be sent anytime host_notification_period 24x7 ; host notifications can be sent anytime service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events service_notification_commands notify-service-by-push ; send service notifications via push host_notification_commands notify-host-by-push ; send host notifications via push register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE! }