21x9.org | System Administration | Home Automation | Smart Home
31.01.2013

nagios/icinga: Push Notification

Die beste Serverüberwachung hilft nichts, wenn man nicht über einen Ausfall zeitnah informiert wird. Meist wird hier eine Benachrichtigung per E-Mail angeboten, die natürlich durchaus tauglich ist. Wer die Info schneller braucht setzt häufig auf SMS. SMS ist aber im Zweifel teuer oder kompliziert einzurichten. Wer ein iOS-Gerät hat kann hier auf Push-Notifications ausweichen.

Eine elegante Möglichkeit ist die Nutzung von http://prowlapp.com, eigentlich für das Zusammenspiel des vom Mac bekannten Tools growl bietet die iOS-App prowl die Möglichkeit per http-Request Nachrichten per Push auf ein iOS-Gerät zu senden. Hierzu ist nur eine kostenlose Registrierung nötig. Anschließend kann man sich einen API-Key erstellen. Diesen benötigt man um sein iOS-Gerät identifizieren zu können.

Damit nagios oder icinga bei einem Fehler eine Nachricht nicht nur per Mail sondern auch über prowl versenden ist folgende Konfiguration nötig:

# /etc/icinga/commands.cfg

# ‘notify-host-by-prowl’ command definition
define command{
command_name notify-host-by-prowl
command_line    wget 'https://prowlapp.com/publicapi/add?apikey=$APIKEY&application=Nagios&event=$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **&description=Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$ Date/Time: $LONGDATETIME$&priority=1&url=https://21x9.org/icingaurl/' -o /dev/null --no-check-certificate -O /dev/null
}

# ‘notify-service-by-prowl’ command definition
define command{
command_name    notify-service-by-prowl
command_line    wget 'https://prowlapp.com/publicapi/add?apikey=$APIKEY&application=Nagios&event=$NOTIFICATIONTYPE$ Service: $SERVICEDESC$ **&description=Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Date/Time: $LONGDATETIME$ Additional Info: $SERVICEOUTPUT$&priority=1&url=https://21x9.org/icingaurl/' -o /dev/null --no-check-certificate -O /dev/null
}

In Zeile 6 und 12 ist $APIKEY durch den bei http://prowlapp.com erzeugten API-Key zu ersetzen.

# /etc/icinga/objects/contacts_nagios2.cfg

service_notification_commands   notify-service-by-email,notify-service-by-prowl
host_notification_commands      notify-host-by-email,notify-host-by-prowl

Nachdem die Konfiguration aktiviert wurde (/etc/init.d/icinga restart) und die Prowl-App auf dem iOS-Gerät installiert wurde steht der Fehlerbenachrichtigung nichts mehr im Wege.

Tags: imported

Tags

imported

Feeds

Atom 1.0 RSS JSON
  • Datenschutz
  • Impressum
  • Archiv