Skip to content

Commit 57994b0

Browse files
committed
Curl timeouts (eg. IPv6 Network with non working PUTMD) have teh effect for CheckMK that the whole notify process will aborted and not only this single plugin.
Added a timeout to the curl request (if you get no connect in 5 sec. forgot it ;)). With this the other notifications plugins are executed as expected from the CheckMK executor Sample log output: 2024-07-27 21:05:16,787 [20] [cmk.base.notify] Output: curl: (28) Operation timed out after 5001 milliseconds with 0 out of 0 bytes received 2024-07-27 21:05:16,788 [20] [cmk.base.notify] Output: Not able to send Telegram message 2024-07-27 21:05:16,789 [20] [cmk.base.notify] Output: 2024-07-27 21:05:16,789 [20] [cmk.base.notify] Plugin exited with code 2 .. other notification plugins following and working
1 parent 077e4ce commit 57994b0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Edit your user and enter your Group/Chat-ID
186186

187187
## TROUBLESHOOTING
188188
For more details and troubleshooting with parameters please check:
189-
* Check_MK notification logfile: /omd/sites/{sitename}/var/log/notify.log
189+
* Check_MK notification logfile: ```tail -f /omd/sites/{sitename}/var/log/notify.log```
190190
* [Check_MK Manual > Notifications > Chapter: 11.3. A simple example](https://docs.checkmk.com/latest/en/notifications.html#H1:Real)
191191
* [[Feature-Request] Multiple Alert Profiles](https://github.com/filipnet/checkmk-telegram-notify/issues/3)
192192

check_mk_telegram-notify.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ MESSAGE+="%0AIPv4: ${NOTIFY_HOST_ADDRESS_4} %0AIPv6: ${NOTIFY_HOST_ADDRESS_6}%0A
102102
MESSAGE+="${NOTIFY_SHORTDATETIME} | ${OMD_SITE}"
103103

104104
# Send message to Telegram bot
105-
response=$(curl -S -s -q -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" -d chat_id="${CHAT_ID}" -d text="${MESSAGE}")
105+
response=$(curl -S -s -q --connect-timeout 5 -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" -d chat_id="${CHAT_ID}" -d text="${MESSAGE}")
106106
if [ $? -ne 0 ]; then
107107
echo "Not able to send Telegram message" >&2
108108
echo $response >&2
109109
exit 2
110110
else
111+
echo "Telegramm message send sucessfull" >&2
111112
exit 0
112113
fi

0 commit comments

Comments
 (0)