Pingmonitor is a bash script that can ping several targets at regular intervals and send notifications using a Telegram bot when a host is down/up.
Its small size and few dependencies makes it a good fit for home routers.
This script needs bash 4 and curl to work.
TL;DR: get the token and chat id, paste them in the config file, move the
config file to /etc and create a new service.
First clone the repo:
git clone https://github.com/canizarex/pingmonitor.gitor download a copy if git is not installed in your device:
wget https://github.com/canizarex/pingmonitor/archive/master.zipStart a new conversation with @botfather and send the comand /newbot. Then
follow the instructions until you get your token.
As per the official documentation: "The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot."
See detailed instructions here: https://core.telegram.org/bots
Now that your bot is created, start a conversation with it and get the chat_id of that conversation using curl:
curl https://api.telegram.org/bot<your_token>/getUpdatesOnce you have the response, look for a string like the one below:
"chat":{"id":123456789,The config file just needs the token and the chat id, so copy them into the pingmonitor.conf file. It should look like this:
token="110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"
chat_id=123456789
Now copy the config file to /etc since the script expects it to be there.
The script is now ready to run.
However, you may want to run it as a service. If that's the case, just keep in mind that the targets to be monitored are passsed to the script as arguments, so you should have something like this in your service file:
ExecStart=/usr/local/bin/pingmonitor example1.com example2.com example3.comor
procd_set_param command /usr/bin/pingmonitor example1.com example2.com example3.comTake a look to the templates folder to see some service file templates.