Icinga2 Notifications sent over Pushover.net

Achtung! Dieser Artikel ist älter als ein Jahr. Der Inhalt ist möglicherweise nicht mehr aktuell!

I recently switched to Pushover.net for sending my Icinga 2 notifications on my smartphone.

Edit the script

Pushover published many sample implementation scripts on their website. I use the perl and adapted it a bit. It’s stored on my master server under _/etc/icinga2/scripts/pushover.pl_ and contains

#!/usr/bin/perl

use LWP::UserAgent;
use Mozilla::CA;

LWP::UserAgent->new()->post(
 "https://api.pushover.net/1/messages.json", [
 "token" => "myapitoken",
 "user" => "myusertoken",
 "message" => $ENV{'message'},
 "title" => $ENV{'title'},
]);

Over inject the content to send over the environment variables message and title. That was much easier than building parameter parsing and checking around it. For my private use it’s okay. In business cases I would do something like parameter and type checking.

Creating the NotificationCommand

Icinga 2 has to know how to call the script and pass the parameters to the script. We need a NotificationCommand for that. Mine is stored under /etc/icinga2/zones.d/master/commands/pushover.conf and contains the following:

object NotificationCommand "push-notification" {
 import "plugin-notification-command"

 command = [ SysconfDir + "/icinga2/scripts/pushover.pl" ]

 env = {
 title = "$service.display_name$ on $host.display_name$: Status changed to $service.state$"
 message = "$service.output$"
 }
}

You can of course change „title“ and „message“ to your needs. If you let it unchanged it’ll look like this:

pushover_overview


Du hast einen Kommentar, einen Wunsch oder eine Verbeserung? Schreib mir doch eine E-Mail! Die Infos dazu stehen hier.

🖇️ = Link zu anderer Webseite
🔐 = Webseite nutzt HTTPS (verschlüsselter Transportweg)
Zurück