-
-
Save Bambarello/9d1d9b833f95dbe9b120beed51f4e1bb to your computer and use it in GitHub Desktop.
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 | |
set -e | |
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH" | |
TEXTFILE_COLLECTOR_DIR=/var/lib/prometheus/node-exporter | |
FILENAME=solana_active_stake.prom | |
metrics_prefix=solana_monit_mainnet | |
ALL=$(timeout 45 solana validators --output json | jq -r '.currentValidators[] |[.identityPubkey, .activatedStake/1000000000] | @csv' ) | |
ACTIVATED_STAKE=$(echo "$ALL" | awk -F"," -v prometheus_metric="${metrics_prefix}_activated_stake" ' { print prometheus_metric"{pubkey="$1"} "$2 } ' ) | |
cat << EOF > "$TEXTFILE_COLLECTOR_DIR/$FILENAME.$$" | |
# HELP ${metrics_prefix}_activated_stake | |
# TYPE ${metrics_prefix}_activated_stake gauge | |
$ACTIVATED_STAKE | |
EOF | |
mv "$TEXTFILE_COLLECTOR_DIR/$FILENAME.$$" "$TEXTFILE_COLLECTOR_DIR/$FILENAME" |
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 | |
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH" | |
TEXTFILE_COLLECTOR_DIR=/var/lib/prometheus/node-exporter | |
FILENAME=solana_block_production.prom | |
metrics_prefix=solana_monit_mainnet | |
ALL=$(timeout 45 solana block-production 2>&1 | grep -v "Identity Pubkey" | grep -v "using data from" | grep -v ":" | grep . | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | sed -e 's/\s\+/,/g' | sed 's/%//g' ) | |
epoch=$(solana epoch) | |
EPOCH=$(echo ${metrics_prefix}_epoch ${epoch}) | |
LEADER_SLOTS=$(echo "$ALL" | awk -F, '{print $1,$2}' | sed -ne 's/^\([a-zA-Z0-9]\+\) \(.*\)$/'${metrics_prefix}'_leader_slots{pubkey="\1", epoch="'${epoch}'"} \2/p') | |
BLOCKS_PRODUCED=$(echo "$ALL" | awk -F, '{print $1,$3}' | sed -ne 's/^\([a-zA-Z0-9]\+\) \(.*\)$/'${metrics_prefix}'_blocks_produced{pubkey="\1", epoch="'${epoch}'"} \2/p') | |
BLOCKS_SKIPPED=$(echo "$ALL" | awk -F, '{print $1,$4}' | sed -ne 's/^\([a-zA-Z0-9]\+\) \(.*\)$/'${metrics_prefix}'_blocks_skipped{pubkey="\1", epoch="'${epoch}'"} \2/p') | |
BLOCKS_SKIPPED_PERC=$(echo "$ALL" | awk -F, '{print $1,$5}' | sed -ne 's/^\([a-zA-Z0-9]\+\) \(.*\)$/'${metrics_prefix}'_blocks_skipped_percent{pubkey="\1", epoch="'${epoch}'"} \2/p') | |
cat << EOF > "$TEXTFILE_COLLECTOR_DIR/$FILENAME.$$" | |
# HELP ${metrics_prefix}_epoch Current epoch | |
# TYPE ${metrics_prefix}_epoch counter | |
$EPOCH | |
# HELP ${metrics_prefix}_leader_slots Leader slots during epoch | |
# TYPE ${metrics_prefix}_leader_slots gauge | |
$LEADER_SLOTS | |
# HELP ${metrics_prefix}_blocks_produced Blocks produced during epoch | |
# TYPE ${metrics_prefix}_blocks_produced gauge | |
$BLOCKS_PRODUCED | |
# HELP ${metrics_prefix}_blocks_skipped Blocks skipped during epoch | |
# TYPE ${metrics_prefix}_blocks_skipped gauge | |
$BLOCKS_SKIPPED | |
# HELP ${metrics_prefix}_blocks_skipped_percent Percent of skipped blocks during epoch | |
# TYPE ${metrics_prefix}_blocks_skipped_percent gauge | |
$BLOCKS_SKIPPED_PERC | |
EOF | |
mv "$TEXTFILE_COLLECTOR_DIR/$FILENAME.$$" "$TEXTFILE_COLLECTOR_DIR/$FILENAME" |
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 | |
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH" | |
TEXTFILE_COLLECTOR_DIR=/var/lib/prometheus/node-exporter | |
FILENAME=solana_delinquent_validators.prom | |
metrics_prefix=solana_monit_mainnet | |
ALL=$(timeout 45 solana validators --output json | jq .delinquentValidators[].identityPubkey -r ) | |
DELINQUENT=$(echo "$ALL" | sed -ne 's/^\(.*\)$/solana_monit_mainnet_delinquent{pubkey="\1"} 1/p' ) | |
cat << EOF > "$TEXTFILE_COLLECTOR_DIR/$FILENAME.$$" | |
# HELP ${metrics_prefix}_delinquent | |
# TYPE ${metrics_prefix}_delinquent gauge | |
$DELINQUENT | |
EOF | |
mv "$TEXTFILE_COLLECTOR_DIR/$FILENAME.$$" "$TEXTFILE_COLLECTOR_DIR/$FILENAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment