-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add emojis according to notification state #7
Conversation
Thanks 👌! |
@@ -1,5 +1,5 @@ | |||
#!/bin/bash | |||
# Push Notification (using Telegram) | |||
# Push Notification with Emojis (using Telegram) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment in line 2 should "not" be changed, because Check_MK uses it for GUI configuration, so existing installations would have an impact.
Push Notification (using Telegram)
@@ -58,9 +58,30 @@ else | |||
echo "Invalid privacy parameter, check your Check_MK settings." >&2 | |||
fi | |||
|
|||
# Set an appropriate emoji for the current state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the UTF-8 encoded emojis in the source code to the "bytes (UTF-8)" notation. This makes more sense from my point of view for compatibility and customizing. The choice of emojis is a matter of taste.
Set an appropriate emoji for the current state
Feel free to change the emoji to your own taste. This is done by customizing the UTF8 code. Examples here: https://apps.timwhitlock.info/emoji/tables/u$
if [[ ${NOTIFY_WHAT} == "SERVICE" ]]; then
STATE="${NOTIFY_SERVICESHORTSTATE}"
else
STATE="${NOTIFY_HOSTSHORTSTATE}"
fi
case "${STATE}" in
OK|UP)
EMOJI=$'\xE2\x9C\x85' # white heavy check mark
;;
WARN)
EMOJI=$'\xE2\x9A\xA0' # warning sign
;;
CRIT|DOWN)
EMOJI=$'\xF0\x9F\x86\x98' # squared sos
;;
UNKN)
EMOJI=$'\xF0\x9F\x94\x84' # anticlockwise downwards and upwards open circle arrows
;;
esac
# Create a MESSAGE variable to send to your Telegram bot | ||
MESSAGE="${NOTIFY_HOSTNAME} (${NOTIFY_HOSTALIAS})%0A" | ||
MESSAGE+="${NOTIFY_WHAT} ${NOTIFY_NOTIFICATIONTYPE}%0A%0A" | ||
MESSAGE+="${EMOJI}${NOTIFY_WHAT} ${NOTIFY_NOTIFICATIONTYPE}%0A%0A" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would not generate the space between emoji and text in the variable, but in the code.
MESSAGE+="${EMOJI} ${NOTIFY_WHAT} ${NOTIFY_NOTIFICATIONTYPE}%0A%0A"
Hello, with pleasure! I'm very happy to see others using the module and even contributing valuable input like you do. I have looked at the changes and tested it in the sandbox. Thank you, I like the improvement very much, great idea. I would like to integrate the pull request into the code, but have comments and ideas before. I have already enhanced the code of the pull request as notes. Would you like to make the changes yourself and thus immortalize yourself as a contributor to the project? I would add the README myself afterwards, provide for new screenshots. |
Hello, No need to delay committing as changed! They were all issues I deliberated on myself but guessed wrong as to your preferences:
Thrilled you appreciate the contribution and please feel free to merge your own changes and avoid duplicate typing! ;) p.s. I did add one screenshot after the fact, but if you tell me what other states you'd like screenshots of, then I'll be happy to provide those myself and save you the time (also let me know if you require the IPv6 masked address included; my home router wouldn't cooperate but I can capture images from staging instead). [1]: e.g. Nagios reported an UNREACHABLE state for hosts, which I couldn't find reference to in checkmk's host state output, so I skipped the nice "🚧" emoji I'd found for it... |
Hi,
Thanks for sharing your code! When we switched from Nagios to Checkmk, the feature our team missed from the previous Telegram-notification plug-in we used was the emojis: they found them helpful when scanning through the channel history or quickly parsing a pop-up notification and requested they be restored.
In case you thought the functionality worth providing to others too, may we present this PR for your consideration. Just let us know if there's any changes you'd like made...
Yours gratefully,
Jonathan Barratt
(Intelligent-Bytes)