In order to get Channel Id, first, post any message to the Channel. Then use this link template to get Channel Id:
https://api.telegram.org/bot<YourBOTToken>/getUpdates
Here is a response example:
{
"ok":true,
"result": [
{
"update_id":123,
"channel_post": {
"message_id":48,
"chat": {
"id":-123123123, // this is your channel id
"title":"Notifications",
"type":"channel"
},
"date":1574485277,
"text":"test"
}
}
]
}
Here you will be helped about telegram bots:
https://telegram-bot-sdk.readme.io/reference/sendmessage
I have crafted the upsmon2telegram.sh bash script. First create the file in the right place.
sudo nano /usr/bin/upsmon2telegram.sh
Paste the code. Save it. Exit nano. Make the file executable.
sudo chmod +x /usr/bin/upsmon2telegram.sh
Test it:
NOTIFYTYPE=ONBATT upsmon2telegram.sh Test message
You should receive a message in your telegram channel.
Edit upsmon.confsudo nano /etc/nut/upsmon.conf
RUN_AS_USER rootReboot your system. Pull the plug and see what happens. Have fun.MONITOR ups@localhost 1 user password master
NOTIFYCMD "upsmon2telegram.sh"
NOTIFYMSG ONLINE "UPS %s on line power" NOTIFYMSG ONBATT "UPS %s on battery" NOTIFYMSG LOWBATT "UPS %s battery is low" NOTIFYMSG FSD "UPS %s: forced shutdown in progress" NOTIFYMSG COMMOK "Communications with UPS %s established" NOTIFYMSG COMMBAD "Communications with UPS %s lost" NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding" NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced" NOTIFYMSG NOCOMM "UPS %s is unavailable" NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC NOTIFYFLAG FSD SYSLOG+WALL+EXEC NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC