2.8 KiB
cmk_telegram - Checkmk Telegram Notifications
Telegram notification plugin for the Checkmk monitoring platform.
This is a Telegram adaptation of Berghmans/cmk_discord. It keeps the same notification semantics as far as Telegram allows:
- emoji per Checkmk notification type
- state highlighting via colored status marker
- state transition (
previous -> current) - service fields for host and service
- host/service output
- acknowledgement/downtime comments
- footer with check command, Checkmk site and timestamp
- inline button linking to the failed host/service when a Checkmk site URL is configured
Telegram does not support Discord-style embeds, embed sidebars/colors, webhook usernames or webhook avatars. Those parts are represented with message formatting, colored emoji markers and an inline button.
Installation
Manual installation
On the Checkmk server, switch into the site user and install the notification script:
sudo su - <site-name>
mkdir -p ~/local/share/check_mk/notifications
cp cmk_telegram.py ~/local/share/check_mk/notifications/cmk_telegram.py
chmod +x ~/local/share/check_mk/notifications/cmk_telegram.py
Then restart/refresh Checkmk if needed and create a notification rule.
Package source layout
The src/ folder follows the same source layout as the original MKP-style repository:
src/
info.json
notifications/
cmk_telegram.py
On a Checkmk site you can copy the notification file manually, or use the src directory as the basis for creating an MKP on your Checkmk instance.
Configuration in Checkmk
Go to Setup → Notifications → Add rule and select Telegram Notification.
Parameters:
- Telegram bot token — mandatory, e.g.
123456789:ABCDEF... - Telegram chat ID — mandatory, e.g.
123456789,-1001234567890, or@channelusername - Checkmk site URL — optional, e.g.
https://checkmkhost.mycompany.com/my_monitoring - Telegram message thread ID — optional, for forum topics in supergroups
- Disable notification sound — optional; use
true,1,yes,onto send silently
Getting Telegram values
- Create a bot via
@BotFatherand copy the token. - Add the bot to your target chat/group/channel.
- Send a message to the target chat.
- Retrieve the chat ID with
https://api.telegram.org/bot<TOKEN>/getUpdates, or use an ID helper bot in private chats.
For channels, the bot usually must be an administrator and the chat ID can also be the public channel username, e.g. @my_channel.
Quick local smoke test
This will not contact Telegram, but it verifies that the script builds a Telegram payload:
python3 examples/render_payload.py
License and attribution
This work is derived from Berghmans/cmk_discord, which is licensed under GPL-2.0. Keep GPL-2.0 attribution when redistributing modified versions.