Created
December 22, 2024 17:00
-
-
Save dumbbell/1b603f3e1e7060722d89a1ba150d3de3 to your computer and use it in GitHub Desktop.
Patch to Stakeconomy solanamonitoring
This file contains hidden or 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
diff --git a/monitor.sh b/monitor.sh | |
index ab5518c..13a5e88 100755 | |
--- a/monitor.sh | |
+++ b/monitor.sh | |
@@ -29,16 +29,16 @@ else | |
fi | |
if [ -z $rpcURL ]; then | |
- rpcPort=$(ps aux | grep solana-validator | grep -Po "\-\-rpc\-port\s+\K[0-9]+") | |
+ rpcPort=$(ps aux | grep agave-validator | grep -Po "\-\-rpc\-port\s+\K[0-9]+") | |
if [ -z $rpcPort ]; then echo "nodemonitor,pubkey=$identityPubkey status=4 $now"; exit 1; fi | |
rpcURL="http://127.0.0.1:$rpcPort" | |
fi | |
-noVoting=$(ps aux | grep solana-validator | grep -c "\-\-no\-voting") | |
+noVoting=$(ps aux | grep agave-validator | grep -c "\-\-no\-voting") | |
if [ "$noVoting" -eq 0 ]; then | |
- if [ -z $identityPubkey ]; then identityPubkey=$($cli address --url $rpcURL); fi | |
+ if [ -z $identityPubkey ]; then identityPubkey=$($cli address --ws $rpcURL); fi | |
if [ -z $identityPubkey ]; then echo "auto-detection failed, please configure the identityPubkey in the script if not done"; exit 1; fi | |
- if [ -z $voteAccount ]; then voteAccount=$($cli validators --url $rpcURL --output json-compact | jq -r 'first (.validators[] | select(.identityPubkey == '\"$identityPubkey\"')) | .voteAccountPubkey'); fi | |
+ if [ -z $voteAccount ]; then voteAccount=$($cli validators --ws $rpcURL --output json-compact | jq -r 'first (.validators[] | select(.identityPubkey == '\"$identityPubkey\"')) | .voteAccountPubkey'); fi | |
if [ -z $voteAccount ]; then echo "please configure the vote account in the script or wait for availability upon starting the node"; exit 1; fi | |
fi | |
@@ -46,12 +46,12 @@ validatorBalance=$($cli balance $identityPubkey | grep -o '[0-9.]*') | |
validatorVoteBalance=$($cli balance $voteAccount | grep -o '[0-9.]*') | |
solanaPrice=$(curl -s 'GET' 'https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd' -H 'accept: application/json' | jq -r .solana.usd) | |
openfiles=$(cat /proc/sys/fs/file-nr | awk '{ print $1 }') | |
-validatorCheck=$($cli validators --url $rpcURL) | |
+validatorCheck=$($cli validators --ws $rpcURL) | |
if [ $(grep -c $voteAccount <<< $validatorCheck) == 0 ]; then echo "validator not found in set"; exit 1; fi | |
- blockProduction=$($cli block-production --url $rpcURL --output json-compact 2>&- | grep -v Note:) | |
+ blockProduction=$($cli block-production --ws $rpcURL --output json-compact 2>&- | grep -v Note:) | |
validatorBlockProduction=$(jq -r '.leaders[] | select(.identityPubkey == '\"$identityPubkey\"')' <<<$blockProduction) | |
- validators=$($cli validators --url $rpcURL --output json-compact 2>&-) | |
+ validators=$($cli validators --ws $rpcURL --output json-compact 2>&-) | |
currentValidatorInfo=$(jq -r '.validators[] | select(.voteAccountPubkey == '\"$voteAccount\"')' <<<$validators) | |
delinquentValidatorInfo=$(jq -r '.validators[] | select(.voteAccountPubkey == '\"$voteAccount\"' and .delinquent == true)' <<<$validators) | |
if [[ ((-n "$currentValidatorInfo" || "$delinquentValidatorInfo" )) ]] || [[ ("$validatorBlockTimeTest" -eq "1" ) ]]; then | |
@@ -104,12 +104,14 @@ if [ $(grep -c $voteAccount <<< $validatorCheck) == 0 ]; then echo "validator n | |
logentry="$logentry,version=$version2,pctNewerVersions=$pctNewerVersions,commission=$commission,activatedStake=$activatedStake,credits=$credits,solanaPrice=$solanaPrice" | |
else status=2; fi | |
if [ "$additionalInfo" == "on" ]; then | |
- nodes=$($cli gossip --url $rpcURL | grep -Po "Nodes:\s+\K[0-9]+") | |
- epochInfo=$($cli epoch-info --url $rpcURL --output json-compact) | |
+ nodes=$($cli gossip --ws $rpcURL | grep -Po "Nodes:\s+\K[0-9]+") | |
+ epochInfo=$($cli epoch-info --ws $rpcURL --output json-compact) | |
epoch=$(jq -r '.epoch' <<<$epochInfo) | |
tps=$(jq -r '.transactionCount' <<<$epochInfo) | |
pctEpochElapsed=$(echo "scale=2 ; 100 * $(jq -r '.slotIndex' <<<$epochInfo) / $(jq -r '.slotsInEpoch' <<<$epochInfo)" | bc) | |
- validatorCreditsCurrent=$($cli vote-account $voteAccount | grep credits/slots | cut -d ":" -f 2 | cut -d "/" -f 1 | awk 'NR==1{print $1}') | |
+ validatorCredits=$($cli vote-account $voteAccount | grep credits/max | cut -d ":" -f 2) | |
+ validatorCreditsCurrent=$(echo "$validatorCredits" | cut -d "/" -f 1 | awk 'NR==1{print $1}') | |
+ validatorCreditsMax=$(echo "$validatorCredits" | cut -d "/" -f 2 | awk 'NR==1{print $1}') | |
TIME=$($cli epoch-info | grep "Epoch Completed Time" | cut -d "(" -f 2 | awk '{print $1,$2,$3,$4}') | |
VAR1=$(echo $TIME | grep -oE '[0-9]+day' | grep -o -E '[0-9]+') | |
VAR2=$(echo $TIME | grep -oE '[0-9]+h' | grep -o -E '[0-9]+') | |
@@ -138,8 +140,10 @@ if [ $(grep -c $voteAccount <<< $validatorCheck) == 0 ]; then echo "validator n | |
epochEnds=$(TZ=$timezone date -d "$VAR1 days $VAR2 hours $VAR3 minutes $VAR4 seconds" +"%m/%d/%Y %H:%M") | |
epochEnds=$(( $(TZ=$timezone date -d "$epochEnds" +%s) * 1000 )) | |
- voteElapsed=$(echo "scale=4; $pctEpochElapsed / 100 * 432000" | bc) | |
- pctVote=$(echo "scale=4; $validatorCreditsCurrent/$voteElapsed * 100" | bc) | |
+ voteElapsed=$(echo "scale=4; $pctEpochElapsed / 100 * $validatorCreditsMax" | bc) | |
+ # FIXME: metrics.stakeconomy.com public dashboard divides the value | |
+ # by 16 to adapt to TVC. Multiply by 16 to counteract this. | |
+ pctVote=$(echo "scale=4; $validatorCreditsCurrent/$voteElapsed * 100 * 16" | bc) | |
logentry="$logentry,openFiles=$openfiles,validatorBalance=$validatorBalance,validatorVoteBalance=$validatorVoteBalance,nodes=$nodes,epoch=$epoch,pctEpochElapsed=$pctEpochElapsed,validatorCreditsCurrent=$validatorCreditsCurrent,epochEnds=$epochEnds,pctVote=$pctVote,tps=$tps" | |
fi | |
logentry="nodemonitor,pubkey=$identityPubkey status=$status,$logentry $now" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment