ruined every thing again

This commit is contained in:
2025-10-21 17:27:09 +00:00
parent b3041edbdc
commit e7423780e8
2 changed files with 64 additions and 7 deletions

View File

@@ -61,10 +61,12 @@ notify() {
# sid(text)
sid() { printf '%s' "$1" | cksum | awk '{print $1}'; }
# <stream> | parse_summary
parse_summary() {
sed -n 's/.*"summary":{"total":\([0-9][0-9]*\),"ok":\([0-9][0-9]*\)}.*/\1 \2/p'
jq -r '.status.summary | "\(.total) \(.ok)"'
}
# list_failures
list_failures() {
awk '
BEGIN{FS="\""; u=""; c=""}
@@ -74,6 +76,11 @@ list_failures() {
'
}
# server_status_message(msg_prefix, server, ok_amount, total_amount, fail_list)
server_status_message() {
msg=$(printf '%s: %s [%s/%s]%s' "${1:?}" "${2:?}" "${3:?}" "${4:?}" "$5")
}
# --- main loop ---
# NOTE: remove temp response body on any exit
@@ -110,7 +117,7 @@ while :; do
fails=$(printf '%s' "$body" | list_failures | sed 's/[ ]$//')
[ -n "$fails" ] && fail_list="${fails}"
fi
msg=$(printf '%s: %s [%s/%s]%s' "$msg_prefix" "$srv" "$good" "$tot" "$fail_list")
msg=$(server_status_message "$msg_prefix" "$srv" "$good" "$tot" "$fail_list")
sfile="${STATE_DIR}/$(sid "$srv").state"
last=""; [ -f "$sfile" ] && last=$(cat "$sfile")