Advanced Telegram Plugin - Telegram Plus

Interesting thing that happens upon restart of the virtual machine si:

..@server:~$ sudo systemctl status checkmk-telegram-plus-nadzor
● checkmk-telegram-plus-nadzor.service - CheckMK Telegram Plus Service
     Loaded: loaded (/etc/systemd/system/checkmk-telegram-plus-nadzor.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2023-06-05 10:10:53 CEST; 37min ago
    Process: 2194 ExecStart=/usr/sbin/runuser -l nadzor -c cd /omd/sites/nadzor/local/share/checkmk-telegram-plus && /omd/sites/nadzor/bin/python3 /omd/sites>
   Main PID: 2194 (code=exited, status=1/FAILURE)

Jun 05 10:10:53 server systemd[1]: checkmk-telegram-plus-nadzor.service: Main process exited, code=exited, status=1/FAILURE
Jun 05 10:10:53 server systemd[1]: checkmk-telegram-plus-nadzor.service: Failed with result 'exit-code'.
Jun 05 10:10:53 server systemd[1]: checkmk-telegram-plus-nadzor.service: Scheduled restart job, restart counter is at 5.
Jun 05 10:10:53 server systemd[1]: Stopped CheckMK Telegram Plus Service.
Jun 05 10:10:53 server systemd[1]: checkmk-telegram-plus-nadzor.service: Start request repeated too quickly.
Jun 05 10:10:53 server systemd[1]: checkmk-telegram-plus-nadzor.service: Failed with result 'exit-code'.
Jun 05 10:10:53 server systemd[1]: Failed to start CheckMK Telegram Plus Service.

Any idea as how to avoid it?

And this only happens when you restart the server? If you run systemctl restart checkmk-telegram-plus-nadzor this does not happen? Does it?

Sorry for the leate reply (been on a vacation).
Here is the printout:

admin@kacloudnagios1:~$ systemctl restart checkmk-telegram-plus-chekmkfree1
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'checkmk-telegram-plus-chekmkfree1.service'.
Multiple identities can be used for authentication:
 1.  admin (knagios1)
 2.  USRADMIN (usradmin)
Choose identity to authenticate as (1-2): 2
Password:
==== AUTHENTICATION COMPLETE ===
admin@kacloudnagios1:~$ systemctl status checkmk-telegram-plus-chekmkfree1
× checkmk-telegram-plus-chekmkfree1.service - CheckMK Telegram Plus Service
     Loaded: loaded (/etc/systemd/system/checkmk-telegram-plus-chekmkfree1.serv>
     Active: failed (Result: exit-code) since Fri 2023-06-16 14:10:24 CEST; 11s>
    Process: 2289832 ExecStart=/usr/sbin/runuser -l chekmkfree1 -c cd /omd/site>
   Main PID: 2289832 (code=exited, status=1/FAILURE)
        CPU: 17ms

Reason for different site is that I have tried it on dev/test.
Same is on the production site.

What output gives you?:

cat /omd/sites/<omd_site_name>/var/log/telegram-plus.log

Aren’t you using the same API key for the Telegram bot for both bots?

Interesting feature :slight_smile:
It shows my attempts to use bots but failed to authenticate.
However, as I remember - there was no response to my authenticating request…

NO - I use separate keys as generated for each bot differently.

Will do more testing soon…

Okay that’s funny. So remotely it’s quite difficult for me to find out more.

Regarding the logs, you can also read them out with the new version of the bot via the bot in the app. This makes it easier to analyze problems.

I have described at: 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.

how to uninstall the bot. If necessary, uninstall it on both OMD sites, install it for one site and then again for the other one.

1 Like

Multilanguage Support

Hi guys,

I just wanted to let you know that the bot is now multilingual (as some have requested). At the moment only very small parts are translated and this feature is still experimental. Every language except English can lead to longer response times and possible wrong output. Texts coming from CheckMK are not translated at all to prevent misinformation.

I will try to expand this feature in the future depending on the experience reports achieving a 100% translation in the future, but to start with it is now like this.

Currently, google Translate is still used for the translation. I will try to use a better translation model like Deepl in the future, but this will only be possible as long as it can remain free of charge, and this is still quite difficult to realise with Deepl.

Hello,
as deexno has instructed me - I have done the troubleshooting by using:

systemctl stop checkmk-telegram-plus-<omd_site_name> && /usr/sbin/runuser -l <omd_site_name> -c 'cd /omd/sites/<omd_site_name>/local/share/checkmk-telegram-plus/ && /omd/sites/<omd_site_name>/bin/python3 /omd/sites/<omd_site_name>/local/share/checkmk-telegram-plus/telegram_bot.py'

which revealed that the old API KEY has remained after the update.

 File "/opt/omd/sites/chekmkfree1/local/share/checkmk-telegram-plus/telegram/_bot.py", line 546, in initialize
    raise InvalidToken(f"The token `{self._token}` was rejected by the server.") from exc
telegram.error.InvalidToken: The token `5917540767:nnnkEaZ5cpwttTrtndL_MKkT8AKwODIbcAA` was rejected by the server.

Hence I have uninstalled the plugin and rm -r /omd/sites/<omd_site_name>/local/share/checkmk-telegram-plus, which enabled me to do the successfull “first install”.

From there all went smooth and am now running three separate bots for as many sites :slight_smile:

However - I have noticed that for the use of a bot to query the CMK - the notifications does not have to be configured and (for me) it does not work if configured (no notifications to the bot is delivered automaticaly).

I was facing this issue untill i fixed it by granting all access to the telegram app.