Difference between revisions of "Icinga2 - Notification Scripts for Notificiation on Twitter through Twidge"

 
Line 9: Line 9:
 
         if [ "$SERVICESTATE" = 'UP' ] || [ "$SERVICESTATE" = 'OK' ]
 
         if [ "$SERVICESTATE" = 'UP' ] || [ "$SERVICESTATE" = 'OK' ]
 
         then
 
         then
                         /bin/echo "#$NOTIFICATIONTYPE - SERVICE #$SERVICEDISPLAYNAME is $SERVICESTATE. Sorry for any inconvenience." | twidge -c /etc/icinga2/twidgerc update
+
                         /bin/echo "#$NOTIFICATIONTYPE OK - SERVICE #$SERVICEDISPLAYNAME is $SERVICESTATE. Entschuldigung für die Unannehmlichkeiten." | twidge -c /etc/icinga2/twidgerc update
 
         else
 
         else
                         /bin/echo "#$NOTIFICATIONTYPE - SERVICE #$SERVICEDISPLAYNAME on #$HOSTALIAS is $SERVICESTATE. Will be fixed." | twidge -c /etc/icinga2/twidgerc update
+
                         /bin/echo "#$NOTIFICATIONTYPE - SERVICE #$SERVICEDISPLAYNAME on #$HOSTALIAS is $SERVICESTATE. Wird behoben." | twidge -c /etc/icinga2/twidgerc update
 
         fi
 
         fi
  
fi</pre>
+
fi
 +
</pre>
  
 
=== Host notification script /etc/icinga2/scripts/twitter-host-notification.sh ===
 
=== Host notification script /etc/icinga2/scripts/twitter-host-notification.sh ===
Line 22: Line 23:
 
         /bin/echo "#$NOTIFICATIONTYPE - Server $HOSTALIAS. $NOTIFICATIONCOMMENT" | twidge -c /etc/icinga2/twidgerc update
 
         /bin/echo "#$NOTIFICATIONTYPE - Server $HOSTALIAS. $NOTIFICATIONCOMMENT" | twidge -c /etc/icinga2/twidgerc update
 
else
 
else
         if [ "$SERVICESTATE" = 'UP' ] || [ "$SERVICESTATE" = 'OK' ]
+
         if [ "$HOSTSTATE" = 'UP' ] || [ "$HOSTSTATE" = 'OK' ]
 
         then
 
         then
                         /bin/echo "#$NOTIFICATIONTYPE - SERVER #$HOSTALIAS is $HOSTSTATE. Sorry for any inconvenience." | twidge -c /etc/icinga2/twidgerc update
+
                         /bin/echo "#$NOTIFICATIONTYPE OK - SERVER #$HOSTALIAS is $HOSTSTATE. Bitte entschuldigen Sie die Unannehmlichkeiten." | twidge -c /etc/icinga2/twidgerc update
 
         else
 
         else
                         /bin/echo "#$NOTIFICATIONTYPE - SERVER #$HOSTALIAS is $HOSTSTATE. Will be fixed." | twidge -c /etc/icinga2/twidgerc update
+
                         /bin/echo "#$NOTIFICATIONTYPE - SERVER #$HOSTALIAS is $HOSTSTATE. Problem wird so schnell wie möglich behoben." | twidge -c /etc/icinga2/twidgerc update
 
         fi
 
         fi
  
fi</pre>
+
fi
 +
</pre>
  
  
 
[[Category: Icinga2]]
 
[[Category: Icinga2]]

Latest revision as of 13:53, 18 December 2019

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