Skip to content
Snippets Groups Projects
Commit 840423c4 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

monitor will now be quiet if it can not connect

parent 7b8d39c0
No related branches found
No related tags found
No related merge requests found
...@@ -2,23 +2,14 @@ ...@@ -2,23 +2,14 @@
if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
source ${BFAHOME}/bin/libbfa.sh || exit 1 source ${BFAHOME}/bin/libbfa.sh || exit 1
ERRTEXT="Monitoring failed"
function json_query function json_query
{ {
cmd=$1 local ERRTEXT="Monitoring RPC failed"
params=$2 trap '' ERR
if [ -n "$params" ] json=$( geth_rpc $* )
then trap errtrap ERR
params=",\"parameters\":[$2]"
fi
json=$(
curl -s -H 'Content-type: application/json' -X POST --data "{\"jsonrpc\":\"2.0\",\"method\":\"${cmd}\"${params},\"id\":1}" http://127.0.0.1:$rpcport
)
}
function json_err
{
echo "$json" | jq -r '.result'
} }
function json_arraylength function json_arraylength
...@@ -26,13 +17,9 @@ function json_arraylength ...@@ -26,13 +17,9 @@ function json_arraylength
jq -r length jq -r length
} }
function json_result
{
echo "$json" | jq -r '.result'
}
json_query admin_peers json_query admin_peers
numpeers=$( json_result | json_arraylength ) test -n "${json}" || exit 0
numpeers=$( echo $json | json_arraylength )
statusfile=$( mktemp ) statusfile=$( mktemp )
cleanup "${statusfile}" cleanup "${statusfile}"
chmod 644 "${statusfile}" chmod 644 "${statusfile}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment