deexno/checkmk-telegram-plus

Debian 12 compatibility

virus2500 opened this issue ยท 7 comments

Hi,

since i updated to Debian 12 the bot isn't working anymore ๐Ÿ˜ญ

I tried to uninstall it and reinstall it. There are some warnings regarding "Running pip as the 'root' user can result in broken permissions and conflicting behaviour". But the installation seems to work.

Installation log
  Collecting python-telegram-bot==20.1
    Using cached python_telegram_bot-20.1-py3-none-any.whl (518 kB)
  Collecting httpx[http2]~=0.23.3
    Using cached httpx-0.23.3-py3-none-any.whl (71 kB)
  Collecting certifi
    Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
  Collecting httpcore<0.17.0,>=0.15.0
    Using cached httpcore-0.16.3-py3-none-any.whl (69 kB)
  Collecting rfc3986[idna2008]<2,>=1.3
    Using cached rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)
  Collecting sniffio
    Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
  Collecting h2<5,>=3
    Using cached h2-4.1.0-py3-none-any.whl (57 kB)
  Collecting hyperframe<7,>=6.0
    Using cached hyperframe-6.0.1-py3-none-any.whl (12 kB)
  Collecting hpack<5,>=4.0
    Using cached hpack-4.0.0-py3-none-any.whl (32 kB)
  Collecting h11<0.15,>=0.13
    Using cached h11-0.14.0-py3-none-any.whl (58 kB)
  Collecting anyio<5.0,>=3.0
    Using cached anyio-4.0.0-py3-none-any.whl (83 kB)
  Collecting idna
    Using cached idna-3.4-py3-none-any.whl (61 kB)
  Installing collected packages: rfc3986, sniffio, idna, hyperframe, hpack, h11, certifi, h2, anyio, httpcore, httpx, python-telegram-bot
  Successfully installed anyio-4.0.0 certifi-2023.7.22 h11-0.14.0 h2-4.1.0 hpack-4.0.0 httpcore-0.16.3 httpx-0.23.3 hyperframe-6.0.1 idna-3.4 python-telegram-bot-20.1 rfc3986-1.5.0 sniffio-1.3.0
  WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  Collecting python-telegram-bot[job-queue]==20.1
    Using cached python_telegram_bot-20.1-py3-none-any.whl (518 kB)
  Collecting httpx[http2]~=0.23.3
    Using cached httpx-0.23.3-py3-none-any.whl (71 kB)
  Collecting APScheduler~=3.10.0
    Using cached APScheduler-3.10.4-py3-none-any.whl (59 kB)
  Collecting pytz>=2018.6
    Using cached pytz-2023.3.post1-py2.py3-none-any.whl (502 kB)
  Collecting six>=1.4.0
    Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
  Collecting tzlocal!=3.*,>=2.0
    Using cached tzlocal-5.0.1-py3-none-any.whl (20 kB)
  Collecting certifi
    Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
  Collecting httpcore<0.17.0,>=0.15.0
    Using cached httpcore-0.16.3-py3-none-any.whl (69 kB)
  Collecting rfc3986[idna2008]<2,>=1.3
    Using cached rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)
  Collecting sniffio
    Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
  Collecting h2<5,>=3
    Using cached h2-4.1.0-py3-none-any.whl (57 kB)
  Collecting hyperframe<7,>=6.0
    Using cached hyperframe-6.0.1-py3-none-any.whl (12 kB)
  Collecting hpack<5,>=4.0
    Using cached hpack-4.0.0-py3-none-any.whl (32 kB)
  Collecting h11<0.15,>=0.13
    Using cached h11-0.14.0-py3-none-any.whl (58 kB)
  Collecting anyio<5.0,>=3.0
    Using cached anyio-4.0.0-py3-none-any.whl (83 kB)
  Collecting idna
    Using cached idna-3.4-py3-none-any.whl (61 kB)
  Installing collected packages: rfc3986, pytz, tzlocal, sniffio, six, idna, hyperframe, hpack, h11, certifi, h2, APScheduler, anyio, httpcore, httpx, python-telegram-bot
  Successfully installed APScheduler-3.10.4 anyio-4.0.0 certifi-2023.7.22 h11-0.14.0 h2-4.1.0 hpack-4.0.0 httpcore-0.16.3 httpx-0.23.3 hyperframe-6.0.1 idna-3.4 python-telegram-bot-20.1 pytz-2023.3.post1 rfc3986-1.5.0 six-1.16.0 sniffio-1.3.0 tzlocal-5.0.1
  WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  Collecting python-telegram-bot[callback-data]==20.1
    Using cached python_telegram_bot-20.1-py3-none-any.whl (518 kB)
  Collecting httpx[http2]~=0.23.3
    Using cached httpx-0.23.3-py3-none-any.whl (71 kB)
  Collecting cachetools~=5.3.0
    Using cached cachetools-5.3.1-py3-none-any.whl (9.3 kB)
  Collecting certifi
    Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
  Collecting httpcore<0.17.0,>=0.15.0
    Using cached httpcore-0.16.3-py3-none-any.whl (69 kB)
  Collecting rfc3986[idna2008]<2,>=1.3
    Using cached rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)
  Collecting sniffio
    Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
  Collecting h2<5,>=3
    Using cached h2-4.1.0-py3-none-any.whl (57 kB)
  Collecting hyperframe<7,>=6.0
    Using cached hyperframe-6.0.1-py3-none-any.whl (12 kB)
  Collecting hpack<5,>=4.0
    Using cached hpack-4.0.0-py3-none-any.whl (32 kB)
  Collecting h11<0.15,>=0.13
    Using cached h11-0.14.0-py3-none-any.whl (58 kB)
  Collecting anyio<5.0,>=3.0
    Using cached anyio-4.0.0-py3-none-any.whl (83 kB)
  Collecting idna
    Using cached idna-3.4-py3-none-any.whl (61 kB)
  Installing collected packages: rfc3986, sniffio, idna, hyperframe, hpack, h11, certifi, cachetools, h2, anyio, httpcore, httpx, python-telegram-bot
  Successfully installed anyio-4.0.0 cachetools-5.3.1 certifi-2023.7.22 h11-0.14.0 h2-4.1.0 hpack-4.0.0 httpcore-0.16.3 httpx-0.23.3 hyperframe-6.0.1 idna-3.4 python-telegram-bot-20.1 rfc3986-1.5.0 sniffio-1.3.0
  WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  Collecting watchdog
    Using cached watchdog-3.0.0-py3-none-manylinux2014_x86_64.whl (82 kB)
  Installing collected packages: watchdog
  Successfully installed watchdog-3.0.0
  WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  Collecting translate
    Using cached translate-3.6.1-py2.py3-none-any.whl (12 kB)
  Collecting click
    Using cached click-8.1.7-py3-none-any.whl (97 kB)
  Collecting lxml
    Using cached lxml-4.9.3-cp311-cp311-manylinux_2_28_x86_64.whl (7.9 MB)
  Collecting requests
    Using cached requests-2.31.0-py3-none-any.whl (62 kB)
  Collecting libretranslatepy==2.1.1
    Using cached libretranslatepy-2.1.1-py3-none-any.whl (3.2 kB)
  Collecting charset-normalizer<4,>=2
    Using cached charset_normalizer-3.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
  Collecting idna<4,>=2.5
    Using cached idna-3.4-py3-none-any.whl (61 kB)
  Collecting urllib3<3,>=1.21.1
    Using cached urllib3-2.0.5-py3-none-any.whl (123 kB)
  Collecting certifi>=2017.4.17
    Using cached certifi-2023.7.22-py3-none-any.whl (158 kB)
  Installing collected packages: libretranslatepy, urllib3, lxml, idna, click, charset-normalizer, certifi, requests, translate
  Successfully installed certifi-2023.7.22 charset-normalizer-3.2.0 click-8.1.7 idna-3.4 libretranslatepy-2.1.1 lxml-4.9.3 requests-2.31.0 translate-3.6.1 urllib3-2.0.5
  WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  Cloning into 'checkmk-telegram-plus'...
  remote: Enumerating objects: 331, done.
  remote: Counting objects: 100% (119/119), done.
  remote: Compressing objects: 100% (89/89), done.
  remote: Total 331 (delta 63), reused 68 (delta 30), pack-reused 212
  Receiving objects: 100% (331/331), 7.77 MiB | 7.85 MiB/s, done.
  Resolving deltas: 100% (138/138), done.
  THE INSTALLATION HAS BEEN COMPLETED. NOW CREATE A NOTIFICATION RULE AS EXPLAINED IN THE GIT REPOSITORY.

The telegram-plus.log then showed

2023-09-28 08:52:21,707:WARNING:log_unauthenticated_access:Virus2500 tried to execute the command 'โš™๏ธ ADMIN SETTINGS' but was not authorised to do so!

I then authenticated again
image

But now the bot is constantly crashing because this is all i get

image

โ””โ”€โ•ผ # journalctl -f -u checkmk-telegram-plus-main.service
Sep 28 09:12:35 checkmk systemd[1]: checkmk-telegram-plus-main.service: Failed with result 'exit-code'.
Sep 28 09:12:35 checkmk systemd[1]: checkmk-telegram-plus-main.service: Scheduled restart job, restart counter is at 10.
Sep 28 09:12:35 checkmk systemd[1]: Stopped checkmk-telegram-plus-main.service - CheckMK Telegram Plus Service.
Sep 28 09:12:35 checkmk systemd[1]: Starting checkmk-telegram-plus-main.service - CheckMK Telegram Plus Service...
Sep 28 09:13:35 checkmk systemd[1]: Started checkmk-telegram-plus-main.service - CheckMK Telegram Plus Service.
Sep 28 09:13:41 checkmk systemd[1]: checkmk-telegram-plus-main.service: Main process exited, code=exited, status=137/n/a
Sep 28 09:13:41 checkmk systemd[1]: checkmk-telegram-plus-main.service: Failed with result 'exit-code'.
Sep 28 09:13:41 checkmk systemd[1]: checkmk-telegram-plus-main.service: Scheduled restart job, restart counter is at 11.
Sep 28 09:13:41 checkmk systemd[1]: Stopped checkmk-telegram-plus-main.service - CheckMK Telegram Plus Service.
Sep 28 09:13:41 checkmk systemd[1]: Starting checkmk-telegram-plus-main.service - CheckMK Telegram Plus Service...

The var/log/telegram-plus.log remains silent so there are no new logs after i authenticated.

If there is another log file or a switch i can use to produce more debug output for you please let me know.

Thanks and br
Mike

deexno commented

Can you please try the following (https://github.com/deexno/checkmk-telegram-plus/blob/main/TROUBLESHOOTING.md#faulty-program-start) and send me the output? If you have any privacy concerns about sending everything here, you can also contact me via telegram @deexno.

Hi,

โ””โ”€โ•ผ # omd_site_name=main
systemctl stop checkmk-telegram-plus-$omd_site_name.service

su - $omd_site_name
cd local/share/checkmk-telegram-plus
python3 telegram_bot.py
OMD[main]:~$ cd local/share/checkmk-telegram-plus
OMD[main]:~/local/share/checkmk-telegram-plus$ python3 telegram_bot.py
Killed
OMD[main]:~/local/share/checkmk-telegram-plus$

I didn't press CTRL + C or anything. It just gets killed by itself.

Here the complete config.ini output (replaced the api_token and allowed_users)

โ””โ”€โ•ผ # cat /opt/omd/sites/$omd_site_name/local/share/checkmk-telegram-plus/config.ini
[telegram_bot]
language = en
version = v3.1.0
api_token = 123456789:asdfasdfasdf-xyz8xyz
password_for_authentication = xyzi
allowed_users = Me (myId),
notifications_loud =
notifications_silent =

[check_mk]
site = main

[ai]
model = bard
token =

I doubt there is a problem since i regularly get the "I am back" messages and i can authenticate. So this seems to be ok

Just noticed it's the oom-killer that kills it

2023-09-28T10:50:58.309927+02:00 home kernel: [464116.324146] python3 invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0

Memory isn't an problem

โ””โ”€โ•ผ # free -h
               total        used        free      shared  buff/cache   available
Mem:           4.0Gi       1.7Gi       2.1Gi        10Mi       154Mi       2.3Gi
Swap:          512Mi       512Mi          0B

but when i look at htop while starting the bot it eats up all the remaining ram (about 2Gb) and then gets obviously killed.

deexno commented

Okay, that's weird. You tried everything else in my troubleshooting guide, right? If so, I'll have to test it on a Debian 11 machine.

Hi.... no you don't have to....

I have no idea why but it started working again.

I haven't changed anything since the last time i wrote but i had the service disabled since then.
Today, to go over all the steps again, i started it and..... it's working again o_O I didn't even try any steps from the troubleshooting guide.... it just works.

I honestly have no idea why.

Thanks for your help anyway :)

Hi Deexno

I have installed CheckMk on a dedicated hardware under Debian 12 and then installed Telegram_Plus.

Unfortunately, something doesn't seem to work properly... I only get the menu displayed from time to time - but there is never a response from the bot...

Sometimes I get the following message:
You are not authenticated! ๐Ÿ” When using the bot for the first time, you must authenticate yourself with a password. If you do not do this, the bot ๐Ÿค– will not respond to any of your further requests.

That would explain why nothing comes from the bot

There is also no response to the /authenticate function.

I also revoked the token and reistalled your script - still no success...

When I do the check from last time:
OMD[monitoring]:~$ python3 ~/local/share/checkmk-telegram-plus
/omd/sites/monitoring/bin/python3: can't find 'main' module in '/omd/sites/monitoring/local/share/checkmk-telegram-plus'

looks like a problem with _main-??

OMD[monitoring]:~$ python3 --version
Python 3.12.3

Checkmk Cloud Edition 2.3.0p1

Is this all related to the fact that the new installation of Checkmk monitoring site has the same name as the previous version? Should I or do I have to delete something?

Any help is apprechiated!

Hi, i don't know if @deexno is reading this anymore since the issue is closed. You should probably open a new one.

However the command you used seems wrong. From: https://github.com/deexno/checkmk-telegram-plus/blob/main/TROUBLESHOOTING.md#faulty-program-start

You should use

omd_site_name=<omd_site_name> # CHANGE <omd_site_name> to the name of your OMD site
systemctl stop checkmk-telegram-plus-$omd_site_name.service

su - $omd_site_name
cd local/share/checkmk-telegram-plus
python3 telegram_bot.py

You are runny python3 against an folder (~/local/share/checkmk-telegram-plus) instead of the script inside it (telegram_bot.py).
Follow the guide and put the output in your new issue.

br

The bot seems to be responding to you and seems to be working. It seems that you have configured the bot incorrectly using the page name 'main' (As already @virus2500 said) It's a bit hard to tell from your output. Have you already run through the troubleshooting guide and performed it exactly as described? https://github.com/deexno/checkmk-telegram-plus/blob/main/TROUBLESHOOTING.md#faulty-program-start

If everything described there does not work, please open a new issue with more details such as your process of installing with output from it. Thank you.