Icinga2 - Notification Scripts for Notificiation on Twitter through Twidge

Revision as of 13:53, 18 December 2019 by Ardaut (talk | changes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Twidge must be installed and configured. In Icinga2: You have to configure notification templates and apply it also.

Service notification script /etc/icinga2/scripts/twitter-service-notification.sh

#!/bin/bash
if [ $NOTIFICATIONTYPE = 'CUSTOM' ]
then
        /bin/echo "#$NOTIFICATIONTYPE - Service $SERVICEDISPLAYNAME. $NOTIFICATIONCOMMENT" | twidge -c /etc/icinga2/twidgerc update
else
        if [ "$SERVICESTATE" = 'UP' ] || [ "$SERVICESTATE" = 'OK' ]
        then
                        /bin/echo "#$NOTIFICATIONTYPE OK - SERVICE #$SERVICEDISPLAYNAME is $SERVICESTATE. Entschuldigung für die Unannehmlichkeiten." | twidge -c /etc/icinga2/twidgerc update
        else
                        /bin/echo "#$NOTIFICATIONTYPE - SERVICE #$SERVICEDISPLAYNAME on #$HOSTALIAS is $SERVICESTATE. Wird behoben." | twidge -c /etc/icinga2/twidgerc update
        fi

fi

Host notification script /etc/icinga2/scripts/twitter-host-notification.sh

#!/bin/sh
if [ $NOTIFICATIONTYPE = 'CUSTOM' ]
then
        /bin/echo "#$NOTIFICATIONTYPE - Server $HOSTALIAS. $NOTIFICATIONCOMMENT" | twidge -c /etc/icinga2/twidgerc update
else
        if [ "$HOSTSTATE" = 'UP' ] || [ "$HOSTSTATE" = 'OK' ]
        then
                        /bin/echo "#$NOTIFICATIONTYPE OK - SERVER #$HOSTALIAS is $HOSTSTATE. Bitte entschuldigen Sie die Unannehmlichkeiten." | twidge -c /etc/icinga2/twidgerc update
        else
                        /bin/echo "#$NOTIFICATIONTYPE - SERVER #$HOSTALIAS is $HOSTSTATE. Problem wird so schnell wie möglich behoben." | twidge -c /etc/icinga2/twidgerc update
        fi

fi