Skip to content

Instantly share code, notes, and snippets.

@SilentRhetoric
Last active November 7, 2024 17:41
Show Gist options
  • Select an option

  • Save SilentRhetoric/b8bdddae38e3169cf0004f3a7e4b164b to your computer and use it in GitHub Desktop.

Select an option

Save SilentRhetoric/b8bdddae38e3169cf0004f3a7e4b164b to your computer and use it in GitHub Desktop.
Algorand Participation Node Checker
#!/bin/bash
# nodechecks.sh
# Select between current or archived log
# Add 'node.archive.log' to the var for archive
LOG='node.log'
echo -e 'Checking what the node has been up to!'
echo -e '\nStatus Report'
echo -e '------------------'
goal node status
echo -e '\nParticipation Keys'
echo -e '---------------------'
goal account listpartkeys
echo -e '\nSoftware Version'
echo -e '---------------------'
algod -v
# echo -e '\nUpdate Log'
# echo -e '---------------'
# cat ~/node/update.log
# Get the node address
ADDRESS=$(goal account partkeyinfo | sed -n '/Parent/p' | awk '{print $3}')
# Save the JSON data from onchain blocks and proposed blocks
ONCHAIN_BLOCKS=$(grep 'RoundConcluded' $ALGORAND_DATA/$LOG | grep "\"Sender\":\"$ADDRESS\"")
PROPOSED_BLOCKS=$(grep 'ProposalBroadcast' $ALGORAND_DATA/$LOG)
echo -e '\nLog Report - Recent Consensus Participation'
echo -e '------------------------------------------------'
echo -e 'Blocks Proposed on Chain: '$(echo -n "$ONCHAIN_BLOCKS" | grep -c '^')
echo -e 'Proposals Broadcast: '$(echo -n "$PROPOSED_BLOCKS" | grep -c '^')
echo -e 'Soft Votes: '$(grep 'VoteBroadcast' $ALGORAND_DATA/$LOG | grep -cF '"ObjectStep":1')
echo -e 'Certification Votes: '$(grep 'VoteBroadcast' $ALGORAND_DATA/$LOG | grep -cF '"ObjectStep":2')
echo -e 'Proposals Frozen: '$(grep -c 'froze' $ALGORAND_DATA/$LOG)
# Get the Blocks Proposed and their Date/Time
BLOCKS=$(echo $PROPOSED_BLOCKS | jq ".ObjectRound")
DATETIME=$(echo $PROPOSED_BLOCKS | jq '.time'| tr -d '"')
# Determine if the block proposed was also voted onto the chain
ONCHAIN=''
# Loop through the blocks
for BLOCK in $BLOCKS
do
CHECK=$(echo $ONCHAIN_BLOCKS | grep $BLOCK)
if [ -z "$CHECK" ]; then
ONCHAIN+='\u274c\n'
else
ONCHAIN+='\u2714\n'
fi
done
# Display Block data
echo -e "\n Block\t Onchain\t\tDate/Time"
echo -e "------------------------------------------------------"
if [ -z "$BLOCKS" ];then
echo -e "No blocks proposed\n"
else
paste <(echo "$BLOCKS") <(echo -e "$ONCHAIN") <(echo "$DATETIME")
fi
echo -e 'Checks complete!'
@SilentRhetoric
Copy link
Author

You can run this simple bash script to return a few bits of information about what your Algorand participation node has been doing. It returns:

  • The node status report
  • The participation keys
  • The current software version
  • The update script log
  • Counts of recent proposals and votes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment