2023-10-18 17:04:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
service="docker run --rm" # INSERT the command that started the service to be monitored
|
|
|
|
bot_text="ETH Node running on machine \"gutalax1\" just stopped." # Text that will be sent to the BOT
|
|
|
|
chat_id="194833572" # User ID or group ID where the message will be sent
|
|
|
|
BOT_api_token="194833572:XXXXXXxxxxxxxxxxxxxXXXXXXX" # The API Token of the BOT that will deliver the message
|
|
|
|
|
|
|
|
while node=$(pgrep -f "$service") >/dev/null # checks if service has started
|
|
|
|
do # if YES stay here forever
|
|
|
|
clear # clean the terminal
|
|
|
|
echo "Node is running with PID=$node" # and print a message
|
2024-03-09 13:32:52 +00:00
|
|
|
sleep 1 # wait 1 second to avoid cloging the CPU
|
2023-10-18 17:04:39 +00:00
|
|
|
done # if NOT
|
|
|
|
echo -e "\n\t\tNode stopped\n" # print messages
|
|
|
|
echo -e "Sending Telegram message...\n"
|
|
|
|
|
|
|
|
# And send a curl request with a message to a telegram BOT
|
|
|
|
curl -s -X POST https://api.telegram.org/bot$BOT_api_token/sendMessage -d chat_id=$chat_id -d text="$bot_text"
|
|
|
|
echo
|