mynode/rootfs/standard/usr/bin/mynode-get-bitcoin-ibd-data

42 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-06-16 01:10:22 +00:00
#!/bin/bash
# Need to run as sudo
2022-06-18 03:42:11 +00:00
NUM_HOURS=24
2022-06-21 04:34:37 +00:00
TOTAL=0
2022-06-16 01:10:22 +00:00
export TZ="GMT"
# Check for arg to change hours
if [ "$#" -eq "1" ]; then
NUM_HOURS=$1
fi
2022-06-18 03:42:11 +00:00
echo "Bitcoin Blocks Processed per Hour"
echo "================================="
2022-06-16 01:10:22 +00:00
# Show current hour
d=$(date "+%Y-%m-%dT%H:")
data_check=$(grep --text "$d" /mnt/hdd/mynode/bitcoin/debug.log | wc -l)
if [ "$data_check" -ne "0" ]; then
c=$(grep --text "$d" /mnt/hdd/mynode/bitcoin/debug.log | grep "UpdateTip" | wc -l)
2022-06-21 04:34:37 +00:00
(( TOTAL+=c ))
else
c="No Data"
fi
2022-06-16 01:10:22 +00:00
echo "${d}00 - ${d}59 | $c (current hour)"
# Show historical hours
for (( i=1; i<=$NUM_HOURS; i++ ))
do
d=$(date -d "$i hour ago" "+%Y-%m-%dT%H:")
data_check=$(grep --text "$d" /mnt/hdd/mynode/bitcoin/debug.log | wc -l)
if [ "$data_check" -ne "0" ]; then
c=$(grep --text "$d" /mnt/hdd/mynode/bitcoin/debug.log | grep "UpdateTip" | wc -l)
2022-06-21 04:34:37 +00:00
(( TOTAL+=c ))
else
c="No Data"
fi
2022-06-16 01:10:22 +00:00
echo "${d}00 - ${d}59 | $c"
2022-06-21 04:34:37 +00:00
done
echo ""
echo "Total in $NUM_HOURS hour(s) + current hour | $TOTAL"