Open Nidwan opened 1 year ago
For anyone asking the same question and myself for future reference, here's what I did:
I installed telegram.sh and configured it with my Telegram token and my Chat ID.
Then I edited the btrfsmaintenance configuration file:
# /etc/default/btrfsmaintenance
---
BTRFS_LOG_OUTPUT="telegram"
Finally I edited the btrfsmaintenance script I use (only btrfs-scrub in my case):
# usr/share/btrfsmaintenance/btrfs-scrub.sh
---
case "$BTRFS_LOG_OUTPUT" in
stdout) cat;;
telegram) cat | /bin/bash /usr/local/bin/telegram -;;
journal) systemd-cat -t "$LOGIDENTIFIER";;
syslog) logger -t "$LOGIDENTIFIER";;
none) cat >/dev/null;;
*) cat;;
I'm really not sure it's safe to modify these files, as they could be modified in a future update. Make a backup of your modifications!
Any other possibility to implement Telegram notifications is very welcome, as this is probably far to be ideal.
I'm not sure if there is another standard way to redirect output on a system-wide logging level, adding it into the maintenance scripts is possible but it could be the wrong place. If you need it just for one of the services then it needs another configuration option. Also for telegram it would require the external script due to the access token, but this is fine as you say above.
Hello,
I'm not sure if this is the right place to ask, sorry if it's not.
Is there a way to get Telegram notifications? I would like to receive results of my monthly scrubs on it.
I've tried to modify BTRFS_LOG_OUTPUT in /etc/default/btrfsmaintenance like this but it didn't work:
BTRFS_LOG_OUTPUT="curl -s -X POST https://api.telegram.org/bot<MyTelegramToken>/sendMessage -d chat_id=<MyChatID> -d text="TEST NOTIFICATION""
Even if it works, is it possible to have two BTRFS_LOG_OUTPUT entries, one for stdout and one for Telegram? Or is it the wrong way to go anyway?
Any help would be greatly appreciated. Thanks!