Created
April 20, 2022 01:14
-
-
Save d13co/d78097850854aa39087d1d3afdd2a76c to your computer and use it in GitHub Desktop.
Bash script to track Algorand Indexer progress via journalctl logs
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
#!/bin/bash | |
sleep_duration=10m | |
while true; do | |
block=$(journalctl -u algorand-indexer -n 2 2> /dev/null | grep imported | grep -oE 'r=[0-9]+' | cut -d= -f2) | |
if [ -z "$block" ]; then | |
echo "no block" | |
sleep $sleep_duration | |
continue; | |
fi | |
epoch=$(date +%s) | |
date=$(date --utc) | |
if [ -z "$lastblock" ]; then | |
diff=0 | |
speed=0 | |
else | |
diff=$((block - lastblock)) | |
elapsed=$((epoch - lastepoch)) | |
speed=$((60 * diff / elapsed)) | |
fi | |
echo "$epoch $date $block +$diff $speed/minute" | |
lastblock=$block | |
lastepoch=$epoch | |
sleep $sleep_duration | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment