logo

Nodiums node tracking Bot

With this simple telegram script you will be able to track the status of your node. This bot tracks your p2p connections and notifies you in case something goes wrong!

We need to get API token of our future bot : https://telegram.me/BotFather

Open any editor you like at your server with node. Create file track.sh and paster the following code. Keep in mind that you need to update some values if you are running it not at default ports!

#!/bin/bash
GREEN_COLOR='\033[0;32m'
RED_COLOR='\033[0;31m'
WITHOU_COLOR='\033[0m'
TOKEN=2064126460:AAG-KpV**********NA
CHAT_ID=your chat ID
MESSAGE1="Moniker"
DELAY=60
TR=$'\n'
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
for (( ;; )); do
MESSAGE2=$(curl -s localhost:26657/status | jq .result.sync_info.catching_up)
if
  [ $MESSAGE2 != 'false' ] 
then
curl -s -X POST $URL -d chat_id=$CHAT_ID -d text=$MESSAGE1"-"$MESSAGE2
  fi

for (( timer=$DELAY; timer>0; timer-- ))
        do
                printf "* sleep for ${RED_COLOR}%02d${WITHOU_COLOR} sec\r" $timer
                sleep 1
        done
done

You need to change API token, your Moniker, RPC port and Chat ID (could be taken from chatid_echo_bot

Press CTRL +X +Y and save this script. You need to have something like:

  1. Give permissions to it : chmod a+x track.sh
  2. Open Screen session : screen -S alert (apt-get install screen)
  3. Run script : ./track.sh
  4. Detach from active session : CTRL + a + d

Now you will get notifications in case you lost syncranization!