Siteping is a tiny bash script for monitoring hosts, it notifies you when a host is unavailable. The notification is using the Telegram-Bot API. Before you can use it, create your personal Telegam-Bot token.
More information: https://core.telegram.org/bots
- Install it on your Raspberry PI or your preferred Linux operating system.
- Copy the scripts into YOUR_HOME_DIR (or elsewhere) be sure that the directory is writable.
- Grant execution rights to both scripts
sudo chmod 755 siteping.sh
sudo chmod 755 tpush.sh
-
Edit tpush.sh and replace YOUR_TOKEN with your Telegram-Bot token and the chatId with your chatId.
a) to get the chatId create a group and add the Telegram-BOT to your group
b) post a message in your group
c) openhttps://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
in a browser
d) copy the chat:id from the json respons.
If you get an empty result, add the bot again to the group. -
Edit siteping.sh and add new host names or change the existing host names for your needs. Don't remove the default counter value 1 at the end of each host name. If you do not want to receive a notification every hour, change the default counter value to 5
-
Add siteping.sh as cronjob to run as background process. Edit the crontab
sudo crontab -e
- Add these lines and save your crontab
@reboot /YOUR_HOME_DIR/siteping.sh &
0 * * * * /YOUR_HOME_DIR/siteping.sh &
- Test the notification script, go to your home dir an run the tpush.sh script
cd /YOUR_HOME_DIR
./tpush.sh "hello world"
- If your Telegram app does not receive your message, check the above steps again.
Default setting of siteping.sh
count=5 (Sends a notification every 60 seconds 5 times when a host is down or unavailable.)
interval=60 (Checks the host list every 60 seconds)
timeout=1 (ping timeout 1 second)
- copy siteping.js and tpush.bat to YOUR_HOME_DIR
- Edit tpush.bat and replace YOUR_TOKEN with your Telegram-Bot token and the YOUR_CHAT_ID with your chatId.
- Edit siteping.js as described above
- Open Command prompt WinKey+R type cmd and click OK
- From the windows command line go to YOUR_HOME_DIR and run siteping, e.g.:
cd c:\users\<YOUR_USERNAME>\Documents\
cscript /nologo siteping.js