Advanced Telegram Plugin - Telegram Plus

Hello community,

I am excited to introduce our new Telegram plugin, developed because we needed more functionality than the current Telegram plugin provided (which is still very good).

We needed to not only receive messages from Check_MK as soon as a problem occurs, but also to interactively ask for more information.

Since this is currently difficult due to the lack of a Check_MK app or a comparably good Nagios app, we developed the following project: GitHub - deexno/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.

I won’t go into detail on how it works, but anyone interested can check out the details on GitHub.

I want to note that the bot has only been tested for a few weeks and may still have 1-2 bugs. We have not found any bugs so far, but this could vary depending on the environment.

We have also only tested it with Check_MK >2.0, so I cannot guarantee that it will work with older versions. If you would like to test it and give us feedback, we would appreciate it.

I hope you find it useful and enjoyable to use! :slight_smile:

6 Likes

depending on your exact needs, maybe Let's Check an Android/iOS App for Check_MK - #6 by jochum is useful to you?

We have already seen this app and so far it doesn’t have the functionality we want. Furthermore, we now have the opportunity to implement features more quickly, as this project has apparently not been developed further for a long time. (as far as we have seen)

Furthermore, today I implemented the feature that allows you to view graphs via telegram, which means that we can now see just about everything in telegram.

But thanks, let’s wait and see how it develops and then we can always change over. :slight_smile:

1 Like

Hey @deexno,

I updated “Let’s check” for 2023. Let me know if you need anything, I don’t want to invest to much time into it as long as there’s noone asking for it.

Kind regards,
René

Hi thanks for your offer but we are now well supplied with the Telegram Bot. I will now add that you can reschedule a check via the bot and that you can install it individually for each OMD page, then we will have almost every functionality we need in the bot. :slight_smile:

1 Like

But I should mention that it would be very cool if one day you would fully develop your mobile app so that almost all the functionality is included there. Because I think many of the CheckMK users would need that, and a mobile app can offer some advantages to my bot.

If you require a starting point for functions in the app, you can write to me here via PN, because I could tell you a few things, since we work a lot with CheckMK.

1 Like

I have now released an update that allows you to run a separate bot per omd page. For those who have already installed the bot, please stop the service, delete the folder where you installed the bot and run the install.sh script as described in the Github repository, this will make future updates easier.

Furthermore, some new functions have been added with this feature.

Thank you

I get this:
Traceback (most recent call last):
File “/omd/sites/tycke/local/share/checkmk-telegram-plus/telegram_bot.py”, line 21, in
from telegram.ext import (
ImportError: cannot import name ‘Application’ from ‘telegram.ext’ (/opt/omd/sites/tycke/local/share/checkmk-telegram-plus/telegram/ext/init.py)

This is probably because you have installed a too old Python library from the python-telegram-bot. (Can have several reasons at first).

I assume you have executed the bot via my install script, so try the following.

  1. Try to run the following command, you should get a similar output.
pip3 show python-telegram-bot

Output:

Name: python-telegram-bot
Version: 20.1
Summary: We have made you a wrapper you can't refuse
Home-page: https://python-telegram-bot.org/
Author: Leandro Toledo
Author-email: devs@python-telegram-bot.org
License: LGPLv3
Location: /usr/local/lib/python3.7/dist-packages
Requires: httpx
Required-by:

If the version in this output is <20.0 execute the following commands in your terminal as root. If this works I will update the install script so that this doesn’t happen anymore. Thanks for your help.

# In your case replace <omd_site_name> with tycke
omd_site=<omd_site_name>

telegram_plus_dir=/omd/sites/$omd_site/local/share/checkmk-telegram-plus
telegram_plus_service_name=checkmk-telegram-plus-$omd_site.service

pip3 install --target=$telegram_plus_dir python-telegram-bot==20.1
pip3 install --target=$telegram_plus_dir python-telegram-bot[job-queue]==20.1
pip3 install --target=$telegram_plus_dir python-telegram-bot[callback-data]==20.1

systemctl restart $telegram_plus_service_name

Keep me posted if this helped, I’ll be happy if we can make the install script work for everyone without any problems :slight_smile:

Got it working finally, after changing to python 3.9 and really remove leftover from previous installs.

All right thank you. Then I’ll check again tomorrow which Python version you need to have installed and set that as a prerequisite in the install script.

I hope you have a lot of fun with the bot and you don’t have any further problems.

If you have other requests or similar you can write to me here via PM. :slight_smile:

Excellent app! :slight_smile:
I have integrated it on my TEST/DEV env and am impressed.

What comes to mind is - how the security of the data transferred is handled?

So, security-wise, the bot should be pretty safe.

Only users can authenticate themselves to the bot using a password, so if you don’t have one, you shouldn’t stand a chance.

The data is sent to Telegram using a WebHook over HTTPs, which also makes it happen encrypted. Telegram itself does not have end-to-end encryption, but it should still be encrypted quite well. You can read more about this online, Telegram uses their own way to encrypt chats.

The data may be stored on Telegram servers, whether you trust Telegram in this regard is up to you. I don’t see any problems in our case.

The code of my bot as well as of the libs used is open source, and you are welcome to read it to check if there are any concerns for you.

Of course, any feature added to a system can somehow open up an opportunity for attackers to do unanticipated things. As of now, however, I am not aware of any security flaws. If anyone finds any, please let me know and I will try to close them.

You can also write me a private message and tell me how and what you would improve the bot, I am open to updates if they seem useful to me.

I would also like to know how the installation went for you and if you had any problems. :slight_smile:

1 Like

Thank you very much for the answer as well as the effort put into the development of this plugin :slight_smile:

As for the installation - it went as smooth as it can be.

HOWEVER - I am facing one problem that you might shed some light on.
How can I use this plugin on several sites, based on the same machine?

I have installed the plugin using the “test” site and when I try to install it using the production site - I get warnings during the installation with:

sudo bash install.sh production 588KEYh0xhg PAASS --upgrade

WARNING: Target directory /omd/sites/production/local/share/checkmk-telegram-plus/bin already exists. Specify --upgrade to force replacement.

AND as a result - the BOT created on Telegram - does not start

I have tried a KEY that has working bot BUT the “target” does not change in the working BOT - it stays with the “test” site.
Might be something that I keep overlooking thaugh…

Okay, this has to do with the fact that an attempt is made to install a library twice… Please try to download the installation script again using wget and then installing it again and let me know if it works now. Thank you.

Thank you for the advice.
BUT, the next problem is:

fatal: destination path 'checkmk-telegram-plus' already exists and is not an empty directory.

I presume that this is the final problem.
If I (maybe) modify the library (although I do not know (yet) how) to make “checkmk-telegram-plus2” directory and than choose this one in notification settings…

OR maybe the developer (you?) to install the question “destination directory exists - rename?” :slight_smile:

Okay, I’ll check that right away. I have only tested it for one side so far. I’ll let you know as soon as it works.

Okay, this should now no longer produce any errors. Sorry for the problems, but hopefully it should work now. So please try to download and run the script again.

2 Likes

Well,
the result is a bit ambiguous.
The error does not appear but I have managed to kill the already working bot.
When spare time allows I will look into it a bit deeper…