Created
September 7, 2022 15:45
-
-
Save bassoy/8636998c3a0a3f5372f7997e255727da to your computer and use it in GitHub Desktop.
Query System & Sync Status of Lighthouse (Readiness for the Merge)
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 | |
curlcmd='curl -s -H "accept: application/json" -X GET' | |
host="http://localhost:5052" | |
temp=$(echo "scale=2; $(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000" | bc) | |
printf "Temperature: %.2f C.\n" ${temp} | |
home_avail=$(df -hBG /home --output=avail | grep -v Avail | grep -Eo "[0-9]+.[0-9]+") | |
printf "Available disk space on /home: %s GB.\n" ${home_avail} | |
mem_free=$(echo "scale=2; $(cat /proc/meminfo | grep MemAvailable: | grep -Eo "[0-9]+") / 1024 / 1024" | bc) | |
printf "Available RAM: %.2f GB.\n" ${mem_free} | |
lighthouse_version=$(${curlcmd} "${host}/eth/v1/node/version" | jq ".data.version") | |
printf "Lighthouse version: %s\n" ${lighthouse_version} | |
synced=$(${curlcmd} "${host}/lighthouse/syncing" | jq ".data") | |
printf "Lighthouse beacon node is %s.\n" ${synced,,} | |
peer_number=$(${curlcmd} "${host}/lighthouse/peers/connected" | jq ". | length") | |
printf "Lighthouse number of peers connected: %d.\n" ${peer_number,,} | |
eth1_sync_status=$(${curlcmd} "${host}/lighthouse/eth1/syncing" | jq ".data.eth1_node_sync_status_percentage") | |
printf "Geth is %d percent synced.\n" ${eth1_sync_status} | |
validator0=$(${curlcmd} "${host}/eth/v1/beacon/states/head/validators/0" | jq ".data.status") | |
printf "Status of validator 0 is %s.\n" ${validator0} | |
validator1=$(${curlcmd} "${host}/eth/v1/beacon/states/head/validators/1" | jq ".data.status") | |
printf "Status of validator 1 is %s.\n" ${validator1} | |
validator0_slashed=$(${curlcmd} "${host}/eth/v1/beacon/states/head/validators/0" | jq ".data.validator.slashed") | |
printf "Validator 0 is slashed: %s.\n" ${validator0_slashed} | |
validator1_slashed=$(${curlcmd} "${host}/eth/v1/beacon/states/head/validators/1" | jq ".data.validator.slashed") | |
printf "Validator 1 is slashed: %s.\n" ${validator1_slashed} | |
merge_ready_type=$(${curlcmd} "${host}/lighthouse/merge_readiness" | jq ".data.type") | |
printf "Lighthouse beacon node merge ready type: %s.\n" ${merge_ready_type} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script assumes that you
jq
,curl
andbc
is installed.If your node is running on a remote machine, you can run the script from your local machine by using the following command:
ssh $username@$remote 'bash -s' < query_lighthouse.sh