From 3ad8684007d00ec656805ff52d08d989ae2b8a16 Mon Sep 17 00:00:00 2001 From: "Crypto2099, Corp" Date: Sun, 23 Aug 2020 07:18:32 +0000 Subject: [PATCH] Adding some error checking and throwing an error if we could not connect to the specified Prometheus port. --- liveview.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/liveview.sh b/liveview.sh index 80d2ffb..087fb9a 100755 --- a/liveview.sh +++ b/liveview.sh @@ -8,7 +8,7 @@ # Cardano Stake Pools: BUFFY | SPIKE ## -promport=12798 # You may need to change this to match your configuration +promport=12799 # You may need to change this to match your configuration refreshrate=2 # How often (in seconds) to refresh the view version=$("$(command -v cardano-node)" version) @@ -26,7 +26,7 @@ INFO='\033[1;34m' while true do - data=$(curl localhost:12798/metrics 2>/dev/null) + data=$(curl localhost:$promport/metrics 2>/dev/null) peers=$(grep -oP '(?<=cardano_node_BlockFetchDecision_peers_connectedPeers_int )[0-9]+' <<< "${data}") blocknum=$(grep -oP '(?<=cardano_node_ChainDB_metrics_blockNum_int )[0-9]+' <<< "${data}") @@ -41,6 +41,11 @@ do abouttolead=$(grep -oP '(?<=cardano_node_metrics_Forge_forge_about_to_lead_int )[0-9]+' <<< "${data}") forged=$(grep -oP '(?<=cardano_node_metrics_Forge_forged_int )[0-9]+' <<< "${data}") + if ((uptimens<=0)); then + echo -e "${REKT}COULD NOT CONNECT TO A RUNNING INSTANCE! PLEASE CHECK THE PROMETHEUS PORT AND TRY AGAIN!${NC}" + exit + fi + peers=$(printf "%14s" "$peers") epoch=$(printf "%14s" "$epochnum / $blocknum") slot=$(printf "%14s" "$slotnum")