Skip to content

Instantly share code, notes, and snippets.

@novy4
Last active October 29, 2020 10:25
Show Gist options
  • Save novy4/5bd697af482a4c494a044847bc7c977c to your computer and use it in GitHub Desktop.
Save novy4/5bd697af482a4c494a044847bc7c977c to your computer and use it in GitHub Desktop.
#!/bin/bash
remote_height=$(curl -s https://api.blockcypher.com/v1/eth/main | jq .height)
local_height=$(($(curl -sX POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://127.0.0.1:8545 | jq -r .result)))
re='^[0-9]+$'
if ! [[ $remote_height =~ $re ]] ; then
echo "error: remote_height is not a number" >&2; exit 1
fi
if ! [[ $local_height =~ $re ]] ; then
echo "error: local_height not a number" >&2; exit 1
fi
echo "Blockcypher block height is " $remote_height
echo "Local block height is " $local_height
echo "Difference is " `expr $remote_height - $local_height`
if [[ `expr $remote_height - $local_height` -gt 10 ]]; then
echo "Huston, we have a problem" && sudo systemctl restart openethereum \
curl -s -X POST https://api.telegram.org/botXXX/sendMessage -d chat_id=-YYY -d text="Graph Ethereum Archive Node blocks are stopped to grow";
else
echo "We are doing fine this time, lets check in a while";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment