/checkmk-telegram-plus

This Telegram bot provides an interface to your Check_MK server. It allows you to send automatic error messages (alerts) via Telegram and to manually read out information about hosts and services.

Primary LanguagePythonApache License 2.0Apache-2.0

Telegram Bot

This Telegram bot provides an interface to your Check_MK server. It allows you to send automatic error messages (alerts) via Telegram and to manually read out information about hosts and services.

Examples

Info

This bot is NOT meant to be used in groups.

System recommendations

  • CheckMK Version 2.1.p25 or higher
  • The programs python3, pip3, git, runuser & sed installed on the server

The Installation / Update process

  1. Install the bot.
    Replace the variables in <> with your respective information.
  • omd_site_name (Your OMD Check_MK site which you want to monitor)
  • api_token (You get this token from the BotFather of Telegram)
  • bot_password (This can be a password of your choice, which will be used later to authenticate to the bot)
wget https://raw.githubusercontent.com/deexno/checkmk-telegram-plus/main/install.sh
bash install.sh <omd_site_name> <api_token> <bot_password>
  1. Create a rule that exports the notifications using our new Notification Plugin.

Telegram Bot

For your information, you can use the first parameter to determine whether a notification should be sent loud (notifications_loud) or silent (notifications_silent). Silent notifications pop up in the chat, but the device does not vibrate or make a notification sound. This method can be used, for example, to differentiate between important and unimportant notifications.

To update the bot, simply download the install.sh file again as mentioned above and run it with the 3 required arguments

Uninstall the Bot

  1. Stop the bot
omd_site_name=<omd_site_name>
systemctl stop checkmk-telegram-plus-$omd_site_name
rm /etc/systemd/system/checkmk-telegram-plus-$omd_site_name.service
systemctl daemon-reload
  1. Delete all notification rules you have created regarding this bot (as described in step 2 of the installation).

  2. Clean and remove all data concerning the bot

rm -Rf /omd/sites/$omd_site_name/local/share/check_mk/notifications/telegram_plus_notify_listener
rm -Rf /omd/sites/$omd_site_name/local/share/checkmk-telegram-plus

Usage

Authenticate

By default, the bot doesn't allow any communication until you authenticate with the previously set password in the configuration file. Here's an example:
Telegram Bot

Receive information about hosts and services

Retrieving data manually is easy. After authentication, you should see a new icon next to the keyboard – the menu button. Open the menu and select an option. The bot will ask for necessary info and provide results (as seen in the examples).

Enable and disable notifications

You can enable or disable messages through the bot. "Loud" and "silent" notifications can also be toggled independently. Note that this setting is ONLY FOR YOU, and all other users will still receive their notifications as normal. And they are decativated by default! So don't forget to activate them!
Telegram Bot

Activate the admin settings ONLY for certain users

If you only want to activate the admin settings ONLY for certain users, follow these steps:

  1. Open the config file of the bot
omd_site_name=<omd_site_name>
nano /omd/sites/$omd_site_name/local/share/checkmk-telegram-plus/config.ini
  1. If the option ‘admin_users’ does not yet exist in the config file, create it under the [telegram_bot] tab:
[telegram_bot]
...
allowed_users = XXX
admin_users =
notifications_loud = XXX
...
  1. Whitelist all users for whom you want to activate the admin option by listing their user ID under admin_users. You will find the ID of the respective users under allowed_users once they have verified themselves at the Telegram bot
# Example Config
[telegram_bot]
...
allowed_users = deexno (987654321),adminuser2 (123456789),ViewUser0 (000000000),
admin_users = deexno (987654321),adminuser2 (123456789),
notifications_loud = XXX
  1. Restart the Bot
systemctl restart checkmk-telegram-plus-$omd_site_name.service

Troubleshooting Guide

TROUBLESHOOTING GUIDE 🔨

Mentions and articles about the bot

TUTONAUT
DEVINSIDER

Support my work

Buy Me A Coffee