Use Emoji to represent SERVICESTATE

This commit is contained in:
Jonny007-MKD 2020-10-19 20:07:22 +02:00
parent 807f709a02
commit 5c6e1b560c

View file

@ -90,14 +90,18 @@ do
esac esac
done done
## Build the message's subject case "$SERVICESTATE" in
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!" CRITICAL) SERVICESTATEICON=$'\xF0\x9F\x9F\xA5';;
WARNING) SERVICESTATEICON=$'\xF0\x9F\x9F\xA7';;
OK) SERVICESTATEICON=$'\xF0\x9F\x9F\xA9';;
*) SERVICESTATEICON="[$SERVICESTATE]";;
esac
## Build the message itself ## Build the message itself
NOTIFICATION_MESSAGE=$(cat << EOF NOTIFICATION_MESSAGE=$(cat << EOF
[$SERVICESTATE] $SERVICEDISPLAYNAME is $SERVICESTATE since $LONGDATETIME $SERVICESTATEICON <b>$SERVICEDISPLAYNAME</b> is ${SERVICESTATE} since $LONGDATETIME
Host: $HOSTALIAS (IPv4 $HOSTADDRESS) Host: <b>$HOSTALIAS</b> (IPv4 $HOSTADDRESS)
More info: $SERVICEOUTPUT
EOF EOF
) )
@ -107,6 +111,9 @@ if [ -n "$HOSTADDRESS6" ] ; then
IPv6? $HOSTADDRESS6" IPv6? $HOSTADDRESS6"
fi fi
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
More info: $SERVICEOUTPUT"
## Are there any comments? Put them into the message! ## Are there any comments? Put them into the message!
if [ -n "$NOTIFICATIONCOMMENT" ] ; then if [ -n "$NOTIFICATIONCOMMENT" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
@ -118,12 +125,13 @@ fi
## Are we using Icinga Web 2? Put the URL into the message! ## Are we using Icinga Web 2? Put the URL into the message!
if [ -n "$HAS_ICINGAWEB2" ] ; then if [ -n "$HAS_ICINGAWEB2" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
Get live status:
$HAS_ICINGAWEB2/monitoring/host/show?host=$HOSTALIAS" <a href='$HAS_ICINGAWEB2/monitoring/host/show?host=$HOSTALIAS'>Icinga Web</a>"
fi fi
## Are we verbose? Then put a message to syslog... ## Are we verbose? Then put a message to syslog...
if [ "$VERBOSE" == "true" ] ; then if [ "$VERBOSE" == "true" ] ; then
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
logger "$PROG sends $SUBJECT => Telegram Channel $TELEGRAM_BOT" logger "$PROG sends $SUBJECT => Telegram Channel $TELEGRAM_BOT"
fi fi