Skip to content

Instantly share code, notes, and snippets.

@lukestokes
Last active July 12, 2018 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukestokes/a92e1ee6f264d120c3669b7a1741135c to your computer and use it in GitHub Desktop.
Save lukestokes/a92e1ee6f264d120c3669b7a1741135c to your computer and use it in GitHub Desktop.
Useful script to check the status of your Steem node in conjunction with Steem in a box.
!/usr/bin/env bash
if [ -f notification_sent.txt ]; then
echo "Notice already sent. Exiting."
exit 1
fi
if [ ! -f last_block.txt ]; then
echo "1" > last_block.txt
exit 1
fi
last_saved_block=$(< last_block.txt)
source .env
latest_log_entry=$(docker logs --tail=1 $DOCKER_NAME)
if [[ $latest_log_entry == *"Generated block"* ]]; then
echo "We just mined a block. Exiting."
exit 1
fi
latest_block=$(echo $latest_log_entry | awk '{print $10;}')
# to test, uncomment this next line:
#latest_block="failtest"
if [[ "$latest_block" -gt "$last_saved_block" ]]; then
rm -f possible_problem.txt
echo "We're good. Latest block is... $latest_block"
echo $latest_block > last_block.txt
exit 1
fi
if [ ! -f possible_problem.txt ]; then
now=$(date)
echo $latest_block > possible_problem.txt
echo $latest_block > "past_issues_$now.txt"
exit 1
fi
# Houston, we have a problem!
echo "There seems to be a problem."
echo "Last saved block: $last_saved_block"
echo "Latest block: $latest_block"
python sendnotice.py
echo -e "Something went wrong. Here's what we got for the latest block: $latest_block \r\n" > notification_sent.txt
echo $latest_log_entry >> notification_sent.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment