Skip to content

Commit

Permalink
Fix indent and bump version for gLV
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlrt committed Jul 30, 2024
1 parent 380062f commit 9ce2b1d
Showing 1 changed file with 68 additions and 77 deletions.
145 changes: 68 additions & 77 deletions scripts/cnode-helper-scripts/gLiveView.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ setTheme() {
# Do NOT modify code below #
######################################

GLV_VERSION=v1.30.0
GLV_VERSION=v1.30.1

PARENT="$(dirname $0)"

Expand Down Expand Up @@ -775,21 +775,18 @@ unset cpu_now cpu_last
####################################

mithrilSignerVars() {
# Require MITHRIL_SIGNER_ENABLED or do not proceed to source files or check ports.
if [[ "${MITHRIL_SIGNER_ENABLED}" == "Y" ]] ; then
# mithril.env sourcing needed to have values in ${METRICS_SERVER_IP} and ${METRICS_SERVER_PORT}
. ${CNODE_HOME}/mithril/mithril.env
signerMetricsEnabled=$(grep -q "ENABLE_METRICS_SERVER=true" ${CNODE_HOME}/mithril/mithril.env && echo "true" || echo "false")
if [[ "${signerMetricsEnabled}" == "true" ]] ; then
mithrilSignerMetrics=$(curl -s "http://${METRICS_SERVER_IP}:${METRICS_SERVER_PORT}/metrics" 2>/dev/null | grep -v -E "HELP|TYPE" | sed 's/mithril_signer_//g')
SIGNER_METRICS_HTTP_RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null --connect-timeout 2 http://${METRICS_SERVER_IP}:${METRICS_SERVER_PORT}/metrics)
if [[ "$SIGNER_METRICS_HTTP_RESPONSE" -eq 200 ]] ; then
signerServiceStatus='online'
else
signerServiceStatus='offline'
fi
unset SIGNER_METRICS_HTTP_RESPONSE
# mithril.env sourcing needed to have values in ${METRICS_SERVER_IP} and ${METRICS_SERVER_PORT}
. ${CNODE_HOME}/mithril/mithril.env
signerMetricsEnabled=$(grep -q "ENABLE_METRICS_SERVER=true" ${CNODE_HOME}/mithril/mithril.env && echo "true" || echo "false")
if [[ "${signerMetricsEnabled}" == "true" ]] ; then
mithrilSignerMetrics=$(curl -s "http://${METRICS_SERVER_IP}:${METRICS_SERVER_PORT}/metrics" 2>/dev/null | grep -v -E "HELP|TYPE" | sed 's/mithril_signer_//g')
SIGNER_METRICS_HTTP_RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null --connect-timeout 2 http://${METRICS_SERVER_IP}:${METRICS_SERVER_PORT}/metrics)
if [[ "$SIGNER_METRICS_HTTP_RESPONSE" -eq 200 ]] ; then
signerServiceStatus='online'
else
signerServiceStatus='offline'
fi
unset SIGNER_METRICS_HTTP_RESPONSE
fi
}

Expand Down Expand Up @@ -1455,68 +1452,62 @@ while true; do
fi
fi

# Mithril Signer Section
mithrilSignerVars

if [[ "${MITHRIL_SIGNER_ENABLED}" == "Y" ]] ; then

printf "${mithrildivider}\n" && ((line++))

get_metric_value() {
local metric_name="$1"
local metric_value
while IFS= read -r line; do
if [[ $line =~ ${metric_name}[[:space:]]+([0-9]+) ]]; then
metric_value="${BASH_REMATCH[1]}"
echo "$metric_value"
return
fi
done <<< "$mithrilSignerMetrics"
}

metrics=(
"runtime_cycle_total_since_startup"
"signer_registration_success_last_epoch"
"signer_registration_success_since_startup"
"signer_registration_total_since_startup"
"signature_registration_success_last_epoch"
"signature_registration_success_since_startup"
"signature_registration_total_since_startup"
)

cycle_total_VAL=$(get_metric_value "runtime_cycle_total_since_startup")
signer_reg_epoch_VAL=$(get_metric_value "signer_registration_success_last_epoch")
signer_reg_success_VAL=$(get_metric_value "signer_registration_success_since_startup")
signer_reg_total_VAL=$(get_metric_value "signer_registration_total_since_startup")
signatures_epoch_VAL=$(get_metric_value "signature_registration_success_last_epoch")
signatures_reg_success_VAL=$(get_metric_value "signature_registration_success_since_startup")
signatures_reg_total_VAL=$(get_metric_value "signature_registration_total_since_startup")

if [[ ${VERBOSE} = "Y" ]]; then
printf "${VL} Status : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signerServiceStatus"
printf " : Registered Epoch : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_epoch_VAL"
closeRow
printf "${VL} Cycles : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$cycle_total_VAL"
printf " : Signing in Epoch : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_epoch_VAL"
closeRow
printf "${VL} Signatures : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_reg_success_VAL"
printf " : Total Signatures : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signatures_reg_total_VAL"
closeRow
printf "${VL} Registered : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_success_VAL"
printf " : Registered Total : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_total_VAL"
closeRow
else
printf "${VL} Status : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signerServiceStatus"
printf " : Registered Epoch : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_epoch_VAL"
closeRow
printf "${VL} Cycles : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$cycle_total_VAL"
printf " : Signing in Epoch : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_epoch_VAL"
closeRow
printf "${VL} Signatures : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_reg_success_VAL"
printf " : Total Signatures : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signatures_reg_total_VAL"
closeRow
fi
fi
if [[ "${MITHRIL_SIGNER_ENABLED}" == "Y" ]] ; then
# Mithril Signer Section
mithrilSignerVars
printf "${mithrildivider}\n" && ((line++))
get_metric_value() {
local metric_name="$1"
local metric_value
while IFS= read -r line; do
if [[ $line =~ ${metric_name}[[:space:]]+([0-9]+) ]]; then
metric_value="${BASH_REMATCH[1]}"
echo "$metric_value"
return
fi
done <<< "$mithrilSignerMetrics"
}
metrics=(
"runtime_cycle_total_since_startup"
"signer_registration_success_last_epoch"
"signer_registration_success_since_startup"
"signer_registration_total_since_startup"
"signature_registration_success_last_epoch"
"signature_registration_success_since_startup"
"signature_registration_total_since_startup"
)
cycle_total_VAL=$(get_metric_value "runtime_cycle_total_since_startup")
signer_reg_epoch_VAL=$(get_metric_value "signer_registration_success_last_epoch")
signer_reg_success_VAL=$(get_metric_value "signer_registration_success_since_startup")
signer_reg_total_VAL=$(get_metric_value "signer_registration_total_since_startup")
signatures_epoch_VAL=$(get_metric_value "signature_registration_success_last_epoch")
signatures_reg_success_VAL=$(get_metric_value "signature_registration_success_since_startup")
signatures_reg_total_VAL=$(get_metric_value "signature_registration_total_since_startup")
if [[ ${VERBOSE} = "Y" ]]; then
printf "${VL} Status : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signerServiceStatus"
printf " : Registered Epoch : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_epoch_VAL"
closeRow
printf "${VL} Cycles : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$cycle_total_VAL"
printf " : Signing in Epoch : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_epoch_VAL"
closeRow
printf "${VL} Signatures : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_reg_success_VAL"
printf " : Total Signatures : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signatures_reg_total_VAL"
closeRow
printf "${VL} Registered : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_success_VAL"
printf " : Registered Total : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_total_VAL"
closeRow
else
printf "${VL} Status : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signerServiceStatus"
printf " : Registered Epoch : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signer_reg_epoch_VAL"
closeRow
printf "${VL} Cycles : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$cycle_total_VAL"
printf " : Signing in Epoch : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_epoch_VAL"
closeRow
printf "${VL} Signatures : ${style_values_2}%-${three_col_1_value_width}s${NC}" "$signatures_reg_success_VAL"
printf " : Total Signatures : ${style_values_1}%-${three_col_1_value_width}s${NC}" "$signatures_reg_total_VAL"
closeRow
fi
fi


[[ ${check_peers} = "true" ]] && check_peers=false && show_peers=true && clrScreen && continue
Expand Down

0 comments on commit 9ce2b1d

Please sign in to comment.