AWK Tutorial: How often do you generate a Witness Block? (SteemIt)


unix-where-there-is-a-shell-there-is-a-way AWK Tutorial: How often do you generate a Witness Block? (SteemIt) awk AWK programming BASH Shell linux linux shell SteemIt

unix-where-there-is-a-shell-there-is-a-way

How many hours/minutes or blocks are there since last time you generate a block as a witness? Today we are going to find out the answer using the LINUX AWK programming.

First, we know that if you run docker logs [Your Container ID] you will see lots of log messages, such as:

steemit-witness-docker-logs AWK Tutorial: How often do you generate a Witness Block? (SteemIt) awk AWK programming BASH Shell linux linux shell SteemIt

steemit-witness-docker-logs

The ./run.sh logs prints a tail-ed messages and we can to grep “Generated” to see the list of blocks:

steemit-witness-docker-logs-grep AWK Tutorial: How often do you generate a Witness Block? (SteemIt) awk AWK programming BASH Shell linux linux shell SteemIt

steemit-witness-docker-logs-grep

So the next thing is to get the 8-th column with prints the block number. Using AWK, we know the 8-th column is stored in $8 and we can use the following Linux command to print the number of blocks since last commit and the hours passed (steemit generates a block every 3 seconds);

NR is the row number in AWK, and substr($8, 2) removes the hash tag.

{
  cur=substr($8,2);
  if (NR>1){
    print "blocks=",cur-prev," hours=", (cur-prev)*3/3600
  }
  prev=cur;
}

The complete command is:

docker logs [Replace with your Container ID] | grep "Generated" | awk '{cur=substr($8,2);if (NR>1){print "blocks=",cur-prev," hours=",(cur-prev)*3/3600}prev=cur;}'
docker-steemit-awk-grep-logs-witness AWK Tutorial: How often do you generate a Witness Block? (SteemIt) awk AWK programming BASH Shell linux linux shell SteemIt

docker-steemit-awk-grep-logs-witness

Yeah, I am getting faster and faster… Please help me to achieve my aim of producing a block every hour by voting me as a witness. (SteemIt Witness Post: Just another Witness)

You may also like: 使用AWK来看见证人生成块的速度

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
463 words
Last Post: SteemTool v0.0.9 - Sending Money to Multiple Addresses!
Next Post: Turtle Programming: Fractal Stars, Random, Console, Eraser, SetPC, SetXY, Examples, Wait, Bug Fixes and So much more!

The Permanent URL is: AWK Tutorial: How often do you generate a Witness Block? (SteemIt)

Leave a Reply