Last active
July 12, 2018 04:48
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/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