Updated Bash Script to Monitor Your Witness Node

Hello Witnesses!

I made a little tweak to my witness node monitoring script today as I've received two false positives recently. One of them was after midnight this past weekend while camping with the family. Yes, I opened up my laptop in the tent, tethered through my phone, and logged in to find everything was fine. Grr.

Here's the diff of the changes:

~/steem-docker # diff check_status.sh check_status_2017-09-10 
21c21
< #latest_block="failtest"
---
> #latest_block=""
25d24
<   rm -f possible_problem.txt
27,33d25
< fi
< 
< if [ ! -f possible_problem.txt ]; then
<     now=$(date)
<     echo  $latest_block > possible_problem.txt
<     echo  $latest_block > "past_issues_$now.txt"
<     exit 1

I basically added a second chance test, and I'm recording failures to a dated file for curiosity's sake. It's quick and dirty, but works fairly well.

Here's the full updated script:

#!/usr/bin/env bash
if [ -f notification_sent.txt ]; then
    exit 1
fi

if [ ! -f last_block.txt ]; then
    echo "1" > last_block.txt
    exit 1
fi

last_saved_block=$(< last_block.txt)
latest_log_entry=$(./run.sh logs | tail -n 1)

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 $11;}')
# to test, uncomment this next line:
#latest_block="failtest"
if [[ "$latest_block" -gt "$last_saved_block" ]]; then
  echo "We're good. Latest block is... $latest_block"
  echo $latest_block > last_block.txt
  rm -f possible_problem.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

Now, if you get two errors in a row (I cron this script for every minute), then you'll get the text message/email instead of with every random funky error notice steemd spits out which happens to line up with the moment you test for successful blocks coming in.

You can see my original post here: Bash Script to Monitor Your Witness Node.

Steem on!


Luke Stokes is a father, husband, business owner, programmer, and voluntaryist who wants to help create a world we all want to live in. Visit UnderstandingBlockchainFreedom.com

I'm a Witness! Please vote for @lukestokes.mhth

Sort:  

Ooops! Another witnesses on my list..@lukestokes.mhth

Screenshot_20170911_071343.png

BOOM!!!

Thank you for your support. :)

As always sir! Looking forward to your vision!

I appreciate the work that you and the other witnesses put into maintaining this platform. You were one of the first witnesses I voted for two reasons--1) you give pretty consistent updates and 2) you're one of the first people here I interacted with who is a witness.

Ah, very cool. Thank you. :)

Just out of curiosity and for my own learning....did you decline payout on this post? I noticed the payout amount appears to be crossed out.

Yes, I did. I figured this was of limited value to just witnesses, not my normal followers so I decided to keep those rewards in the reward pool for others.

If interested, here's a discussion about the rewards pool.

Well that answers my long standing question about the little line thru the payouts on some posts lol. Thanks!

Btw that's really cool that you opted to leave that money in the pool. Not many ppl would do that.

@lukestokes - Hehehe - I understand nothing about Bash scripts but can imagine your frustration at being disturbed while of a camping weekend with family!!
Someday - I will understand more on witness nodes and bash scripts - I am reading up. By the way - am now able to do more stuff on SQL, inspired by your comments and your reports! Thanks a ton.

Regards,
vm2904

Very cool! I've been doing SQL for so long it's become a comfortable language for me. Things get really fun when I start building SQL scripts to generate SQL scripts (for mass inserts and updates of specific records). Fun stuff for nerds like me. :)

Ouch - SQL scripts to write SQL scripts? Just when I start feelings that I learnt something, you go and say something like that and I feel 'illiterate' again. Lol. Well - what is life if there is nothing left to learn !

Note to self - ( apart from writing better blogs) - Nose to grindstone again !! 😄😄

Very nice Luke I was just looking for a script to get this done! I appreciate you making it all available here and updating it to limit false positives!

Let me know if you have any questions getting it working.

Hi @lukestrokes . Is there a guide or tutorial that will help me to become a witnes ?

Why do you want to become a witness?

(And yes, there are a number of them if you search around but it's not quite like just putting up a mining server. It's more like running for political office.)

I see ! Ok I will get informed better about this political office :-) Since then have a nice week.

Thanks for the update, glad that I voted for you...thanks for your support too...more success

Thanks for sharing... Love it.

How much upkeep does a Witness Node take once it is up and running?

Not too much, if you're on a good hosting provider. It's more like a 24-hour on call setup. Also, you have to be involved and engaged with the witness discussions in chat and here on the site. It's kind if a labor of love that also rewards you, which is nice. Check @timcliff's weekly resorts to get a feel for what efforts witnesses put in.

Thanks for the info. I'll check that out.

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 58068.07
ETH 3133.85
USDT 1.00
SBD 2.44