Quick and dirty way to monitor your xDai validator #2 for Nethermind

November 8, 2021 written by 01NODE

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

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 20m xdai-validator 2>&1 | grep “0x010101…val_addr”)
if [ “${output}” == “” ]; then
send_message “No New block for the last 20m – check xdai NM-Validator”
sleep 60 & wait

PS: “xdai-validator” is the docker container name. 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.

Shoutout to stakesystems for the help with the script.

We breathe, we give! #WePlant