Skip to content

Instantly share code, notes, and snippets.

@lukestokes
Last active March 10, 2019 10:49
Show Gist options
  • Select an option

  • Save lukestokes/f33b17f1db2244abe35de7ca14a1eeae to your computer and use it in GitHub Desktop.

Select an option

Save lukestokes/f33b17f1db2244abe35de7ca14a1eeae to your computer and use it in GitHub Desktop.
EOS Node notification script
#!/usr/bin/env bash
if [ ! -f last_block.txt ]; then
echo "0" > last_block.txt
fi
if [ ! -f skip_count.txt ]; then
echo "0" > skip_count.txt
fi
send_notice=false
last_saved_block=$(< last_block.txt)
skip_count=$(< skip_count.txt)
latest_block=$(~/eos/build/programs/cleos/cleos --url http://localhost:8888 get info | grep last_irreversible_block_num | awk '{print $2;}' | tr -d ,)
if (( latest_block > last_saved_block )); then
echo "We're good. Latest block is... $latest_block"
echo $latest_block > last_block.txt
echo "0" > skip_count.txt
if [ -f notification_sent.txt ]; then
rm notification_sent.txt
fi
exit 1
fi
if [ -f notification_sent.txt ]; then
send_notice=false
skip_count=$((skip_count+1))
echo "$skip_count" > skip_count.txt
echo "Skip count modulus: $(($skip_count % 30))"
# Send a text every 30 minutes
if (( $skip_count % 30 == 0 )); then
send_notice=true
fi
else
send_notice=true
echo -e "Something went wrong. Here's what we got for the latest block: |$latest_block| \r\n" > notification_sent.txt
fi
if $send_notice; then
date >> logs.txt
tail -n 200 eos.log | grep --line-buffered -v misaligned | tail -n 5 >> logs.txt
echo "There seems to be a problem."
echo "Last saved block: $last_saved_block"
echo "Latest block: $latest_block"
python sendnotice.py
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment