CMK version: 2.0.0p31 (CRE)
OS version: Ubuntu 20.04.5 LTS (focal)
Hi everyone,
I want to send notifications via Signal from a notification script.
When executing the script from within an SSH session in the Bash shell, the UTF-8 characters are processed properly and the Emojis show up in the sent notification.
When the same script is run by Check_MK, all I get is some questionmark characters in the message.
I have tried with and without manually setting the locale to C.UTF-8 and I have verified that this locale is installed and available during the script run.
What is mysterious is that the script using Telegram from this blog post (Checkmk Benachrichtigungen über Telegram versenden | Checkmk) works perfectly fine with the same Emojis.
I use this interface for the Signal API: GitHub - AsamK/signal-cli: signal-cli provides an unofficial commandline and dbus interface for signalapp/libsignal-service-java
This is the notification script:
#!/bin/bash
# Signal Notification
export LANG="C.UTF-8"
if [[ ${NOTIFY_WHAT} == "SERVICE" ]]; then
STATE="${NOTIFY_SERVICESHORTSTATE}"
else
STATE="${NOTIFY_HOSTSHORTSTATE}"
fi
function convertState () {
case "$1" in
OK|UP)
echo '\xE2\x9C\x85' # white heavy check mark
;;
WARN)
echo '\xE2\x9A\xA0' # warning sign
;;
CRIT)
echo '\xF0\x9F\x86\x98' # squared sos
;;
DOWN|UNREACH)
echo '\xE2\x9B\x94' # no entry
;;
UNKN)
echo '\xE2\x9D\x93' # black question mark ornament
;;
esac
}
EMOJI=$(convertState "${STATE}")
MESSAGE="\xF0\x9F\x92\xBB ${NOTIFY_HOSTNAME} (${NOTIFY_HOST_ADDRESS_4})\n"
MESSAGE+="${EMOJI} ${NOTIFY_WHAT} ${NOTIFY_NOTIFICATIONTYPE}\n\n"
if [[ ${NOTIFY_WHAT} == "SERVICE" ]]; then
MESSAGE+="${NOTIFY_SERVICEDESC} "
PREV=$(convertState "${NOTIFY_PREVIOUSSERVICEHARDSHORTSTATE}")
NOW=$(convertState "${NOTIFY_SERVICESHORTSTATE}")
MESSAGE+="${PREV} \xE2\x9E\xA1 ${NOW}\n"
MESSAGE+=" \n${NOTIFY_SERVICEOUTPUT}\n"
else
PREV=$(convertState "${NOTIFY_PREVIOUSHOSTHARDSHORTSTATE}")
NOW=$(convertState "${NOTIFY_HOSTSHORTSTATE}")
MESSAGE+="${PREV} \xE2\x9E\xA1 ${NOW}\n"
MESSAGE+="\n${NOTIFY_HOSTOUTPUT}\n"
fi
MESSAGE+="\n${NOTIFY_SHORTDATETIME}"
/opt/signal-cli/bin/signal-cli -c /opt/signal-cli/config -a <redacted> send -m "`echo -e "$MESSAGE"`" "$NOTIFY_CONTACTPAGER"