wget https://github.com/wormholes-org/wormholes/archive/refs/tags/v0.11.0.tar.gz
bash ./wormholes_install.sh
nano wormholes_monitor.sh
#!/bin/bash
function info(){
cn=0
while true
do
echo "$cn second."
echo "node $1"
rs=`curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","id":64}' https://api.wormholes.com 2>/dev/null`
blockNumbers=$(parse_json $rs "result")
echo "Block height of the whole network: $((16#${blockNumbers:2}))"
rs1=`curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_peerCount","id":64}' 127.0.0.1:$1 2>/dev/null`
count=$(parse_json $rs1 "result")
echo "Number of node connections: $((16#${count:2}))"
rs2=`curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","id":64}' 127.0.0.1:$1 2>/dev/null`
blckNumber=$(parse_json $rs2 "result")
echo "Block height of the whole network: $((16#${blckNumber:2}))"
sleep 5
clear
let cn+=5
done
}
function parse_json(){
if [[ $1 =~ $2 ]];then
echo "${1//\"/}"|sed "s/.*$2:\([^,}]*\).*/\1/"
else
echo "0x0"
fi
}
function main(){
if [[ $# -eq 0 ]];then
info 8545
else
info $1
fi
}
main "$@"
bash ./wormholes_monitor.sh