Skip to content

Instantly share code, notes, and snippets.

@d13co
Created April 20, 2022 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d13co/d78097850854aa39087d1d3afdd2a76c to your computer and use it in GitHub Desktop.
Save d13co/d78097850854aa39087d1d3afdd2a76c to your computer and use it in GitHub Desktop.
Bash script to track Algorand Indexer progress via journalctl logs
#!/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