Quick And Dirty Way To Monitor Your Xdai Validator
Quick And Dirty Way To Monitor Your Xdai Validator

Quick and dirty way to monitor your xDai validator

A quick and dirty way to monitor your xDai nethermind validator using a bash script and a telegram bot.
November 5, 2021 written by 01NODE

A quick and dirty way to monitor your xDai validator using a bash script and a telegram bot.

!/bin/bash
TELEGRAM_AUTH_TOKEN=auth_token
TELEGRAM_CHAT_ID=chat_id
curl_w() {
curl \
--retry 10 \
--retry-delay 0 \
--retry-max-time 120 \
--connect-timeout 0.5 \
--retry-connrefused \
-sf "$@"
}
send_message() {
curl_w -w "\n" -X POST "https://api.telegram.org/bot${TELEGRAM_AUTH_TOKEN}/sendMessage" \
-H 'Content-Type: application/json' \
-d "{\"chat_id\": \"${TELEGRAM_CHAT_ID}\", \"text\": \"${*}\", \"disable_notification\": false}"
}
while :; do
output=$(docker logs --since 3m openethereum 2>&1 | grep "New block")
if [ "${output}" == "" ]; then
send_message "No New block for the last 3m - check xdai Node"
sleep 60 & wait
fi
done

Save the above as blocks.sh and chmod +x blocks.sh and than you run it ./blocks.sh [you can run it in screen ]. Don t forget to add your details for the telegram bot, or create one if you don t already have one, there are plenty of guides online for this.

ex: telegram-bot

TADA! you now have alerts if your node does not sign a block in 5 minutes.

Quick And Dirty Way To Monitor Your Xdai Validator
Next article
Copied to clipboard!