From 840423c4e1ead9c1976a5f68d567c4a38f0c2060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Martin-Leg=C3=A8ne?= <robert@nic.ar> Date: Thu, 27 Sep 2018 14:19:07 -0300 Subject: [PATCH] monitor will now be quiet if it can not connect --- bin/monitor.sh | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/bin/monitor.sh b/bin/monitor.sh index 50665ca..312c4d7 100755 --- a/bin/monitor.sh +++ b/bin/monitor.sh @@ -2,23 +2,14 @@ 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 +ERRTEXT="Monitoring failed" function json_query { - cmd=$1 - params=$2 - if [ -n "$params" ] - then - 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' + local ERRTEXT="Monitoring RPC failed" + trap '' ERR + json=$( geth_rpc $* ) + trap errtrap ERR } function json_arraylength @@ -26,13 +17,9 @@ function json_arraylength jq -r length } -function json_result -{ - echo "$json" | jq -r '.result' -} - json_query admin_peers -numpeers=$( json_result | json_arraylength ) +test -n "${json}" || exit 0 +numpeers=$( echo $json | json_arraylength ) statusfile=$( mktemp ) cleanup "${statusfile}" chmod 644 "${statusfile}" -- GitLab