forked from xhinis/Wormholes-Testnet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodemonitoring.sh
35 lines (32 loc) · 1.2 KB
/
nodemonitoring.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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.wormholestest.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(){
echo "${1//\"/}"|sed "s/.*$2:\([^,}]*\).*/\1/"
}
function main(){
if [[ $# -eq 0 ]];then
info 8545
else
info $1
fi
}
main "$@"