OPNsense Forum

Archive => 23.1 Legacy Series => Topic started by: bcookatpcsd on April 23, 2023, 07:29:43 pm

Title: telegram api or otherwise.. smtp2telegram
Post by: bcookatpcsd on April 23, 2023, 07:29:43 pm
Searching brings up old posts regarding this..

Is there a way that I could get notifications about my system status? reboots, update results, etc.?

Reporting section of the manual seems to be about system services.. but I would like the system to reach out and let me know an event happened..

Is there a plugin that possibly I missed that already does this?

Or is the suggestion to setup postfix and relay to my smtp2telegram instance?

Thanks in advance
Title: Re: telegram api or otherwise.. smtp2telegram
Post by: Balogh on April 29, 2023, 01:21:10 pm
I've just tried https://github.com/matriphe/monit2telegram (https://github.com/matriphe/monit2telegram) for telegram notifications and it works in opnsense with some minor changes like placing the files in /usr/local/{bin,etc} and editing their contents to use these new paths and the correct shell path in Opnsense: /usr/local/bin/bash. bash might also need installing, I don't remember if it comes preinstalled.
Title: Re: telegram api or otherwise.. smtp2telegram
Post by: 0justin8 on October 01, 2023, 10:55:22 pm
Hopefully this thread isn't too old, but I have managed to get this working, sort of. I've gotten all the way to the last part, adding the 2 lines to the config file.

"check file nginx.pid with path /var/run/nginx.pid
    if changed pid then exec "/usr/local/bin/monit2telegram"

The first problem is, nginx.pid doesn't exist. There is a monit.pid file, and if I enter that instead, I still get an error in the monit log "syntax error 'pid' " for line 2.
Also, the monit2telegram file has a line

"/usr/local/bin/sendtelegram -c /etc/telegramrc -m "Monit $MONIT_SERVICE - $MONIT_EVENT at $MONIT_DATE on $MONIT_HOST: $MONIT_ACTION $MONIT_DESCRIPTION.""

If i manually trigger monit2telegram, the message I get is "Monit - at on :" so obviously those $MONIT commands or whatever either are wrong, or are different in Opnsense. I'm not really clear where that data is actually supposed to be pulled from. Any help would be greatly appreciated! Thanks in advance!
Title: Re: telegram api or otherwise.. smtp2telegram
Post by: InTeL3D on October 09, 2023, 01:06:43 pm
Any news? i'm stuck as Justin...
Thank you
Title: Re: telegram api or otherwise.. smtp2telegram
Post by: cookiemonster on October 09, 2023, 01:32:51 pm
I am not using Monit so only from a generic point of view. The last part referenced here seems just an example, and is expecting the user to set a check in Monit, in this case, Monit is running on OPN.
In Justin case it told Monit to test for the presence of nginx.pid file in that path and would only exist if that service was running at the time. Probably he doesn't have nginx running so the test would fail.
Title: Re: telegram api or otherwise.. smtp2telegram
Post by: bcookatpcsd on December 10, 2023, 08:01:13 pm
https://hub.docker.com/r/kostyaesmukov/smtp_to_telegram

Seems to be maintained..

 root@void-d51d87 ~# docker ps -a | grep telegram
2a9a2fb173a0   kostyaesmukov/smtp_to_telegram:latest   "/smtp_to_telegram"      2 weeks ago     Up 2 weeks                             smtp_to_telegram

Code: [Select]
docker run \
    --name smtp_to_telegram \
    --restart unless-stopped \
    -e TZ=America/New_York \
    -e ST_TELEGRAM_CHAT_IDS=xyz123abc456 \
    -e ST_TELEGRAM_BOT_TOKEN=8< SNIP >8 \
    -e ST_TELEGRAM_MESSAGE_TEMPLATE="Subject: {subject}\\n\\n{body}" \
    -d \
    --network host \
    kostyaesmukov/smtp_to_telegram

https://github.com/KostyaEsmukov/smtp_to_telegram

Looks to be a go program.. possibly could be made into a plugin
Title: Re: telegram api or otherwise.. smtp2telegram
Post by: oscars on December 17, 2023, 01:10:33 am
Agreed:

Request

https://github.com/opnsense/core/issues/7080