File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
- # Push Notification (using Telegram)
2
+ # Push Notification with Emojis (using Telegram)
3
3
#
4
4
# Script Name : check_mk_telegram-notify.sh
5
5
# Description : Send Check_MK notifications by Telegram
8
8
# ======================================================================================
9
9
10
10
# Telegram API Token
11
- # Find telegram bot named "@botfarther ", type /mybots, select your bot and select "API Token" to see your current token
11
+ # Find telegram bot named "@botfather ", type /mybots, select your bot and select "API Token" to see your current token
12
12
if [ -z ${NOTIFY_PARAMETER_1} ]; then
13
13
echo " No Telegram token ID provided. Exiting" >&2
14
14
exit 2
58
58
echo " Invalid privacy parameter, check your Check_MK settings." >&2
59
59
fi
60
60
61
+ # Set an appropriate emoji for the current state
62
+ if [[ ${NOTIFY_WHAT} == " SERVICE" ]]; then
63
+ STATE=" ${NOTIFY_SERVICESHORTSTATE} "
64
+ else
65
+ STATE=" ${NOTIFY_HOSTSHORTSTATE} "
66
+ fi
67
+ case " ${STATE} " in
68
+ OK|UP)
69
+ EMOJI=" ✅ "
70
+ ;;
71
+ WARN)
72
+ EMOJI=" ⚠ "
73
+ ;;
74
+ CRIT|DOWN)
75
+ EMOJI=" 🔥 "
76
+ ;;
77
+ UNKN)
78
+ EMOJI=" ❓ "
79
+ ;;
80
+ esac
81
+
61
82
# Create a MESSAGE variable to send to your Telegram bot
62
83
MESSAGE=" ${NOTIFY_HOSTNAME} (${NOTIFY_HOSTALIAS} )%0A"
63
- MESSAGE+=" ${NOTIFY_WHAT} ${NOTIFY_NOTIFICATIONTYPE} %0A%0A"
84
+ MESSAGE+=" ${EMOJI}${ NOTIFY_WHAT} ${NOTIFY_NOTIFICATIONTYPE} %0A%0A"
64
85
if [[ ${NOTIFY_WHAT} == " SERVICE" ]]; then
65
86
MESSAGE+=" ${NOTIFY_SERVICEDESC} %0A"
66
87
MESSAGE+=" State changed from ${NOTIFY_PREVIOUSSERVICEHARDSHORTSTATE} to ${NOTIFY_SERVICESHORTSTATE} %0A"
You can’t perform that action at this time.
0 commit comments