Hi There!
Recently my pool missed to create a valid block. and the reason was that the block was produced not on the highest block but on the previous one. So I tried to calculate what was the delay time between the highest block production time and the actual time when the pool was received it.
so here is the command - right now it only works on text format, not json format:
grep -h "new tip" node.log | sed -rn "s/\[(.*)\].\[(.*)\].* ([0-9]+)/\2,\3/p" | awk -F, -v threshold=2 '{"date +%s.%3N -d\""$1"\""|getline actualTime; delay=actualTime-$2-1591566291; sum+=delay; if (delay > threshold ) print $1 " " delay;} END {print "AVG=", sum/NR}'
and here is an example line which will be matched:
[dell:cardano.node.ChainDB:Notice:265] [2021-03-25 21:04:33.57 UTC] Chain extended, new tip: 720267abd1f74bfcc9eb6a107ffe09c95188e371d6b6fd17907771e47c66d5bc at slot 25139982
details of the command
-
grep -h "new tip" node.log
- find the line which contains “new tip” in file node.log -
sed -rn "s/\[(.*)\].\[(.*)\].* ([0-9]+)/\2,\3/p"
- extract actual time (2021-03-25 21:04:33.57 UTC) and slot (25139982) and print the numbers between comma -
awk -F,
- use comma as splitter -
-v threshold=2
- define threshold, which is 2 sec -
date +%s.%3N -d”"$1"""|getline actualTime
- convert actual time to sec (1st column) -
delay=actualTime-$2-1591566291
calculate delay by extracting actual time and slot time (1591566291 is a kind of magic number - it tells what was the time in sec at slot 0) -
sum+=delay
- collect all the delay times -
if (delay > threshold ) print $1 " " delay
- print actual time and delay if the delay is more than the threshold -
END {print “AVG=”, sum/NR}
- print the average delay time at the end…
so the out of this command when executed on logs of my block producer node:
2021-03-21 22:14:05.65 UTC 2.65
2021-03-21 22:17:33.26 UTC 4.26
2021-03-21 22:40:25.05 UTC 3.05
2021-03-21 22:55:47.29 UTC 27.29
2021-03-21 23:14:01.77 UTC 4.77
2021-03-21 23:15:38.31 UTC 2.31
2021-03-21 23:32:10.47 UTC 2.47
2021-03-21 23:33:27.59 UTC 3.59
2021-03-21 23:47:22.26 UTC 16.26
2021-03-21 23:51:37.23 UTC 17.23
2021-03-21 23:56:10.97 UTC 4.97
AVG= 0.684816
so the node gets the blocks with an average of 0.685 milisec delay after it was produced.
guess what - my block was created when the delay was ~16 sec… at 2021-03-21 23:47:22.26 UTC
I think this can be an other metric or a performance indicator of a node.
So - what is the network delay of you pool? Would be curious what is the number of others!