Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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