monitoring: coloured SUMMARY block at end of run

Severity badges for OK/ERROR/WARN/INFO/BLOCKER counts plus
verdict line (all clear / warnings only / failed).
This commit is contained in:
Hernâni Marques 2026-07-17 19:03:49 +02:00
parent 6a6300f4ab
commit e82ee9a70b
No known key found for this signature in database

View file

@ -722,6 +722,7 @@ section() {
}
summary() {
local blk_n=${#BLOCKERS[@]}
echo ""
# final progress line (no _take_tid — plain printf)
if [ "${PROGRESS_OFF:-0}" != "1" ] && [ "$PROGRESS_DONE" -gt 0 ]; then
@ -733,24 +734,24 @@ summary() {
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
fi
if [ "$GLOBAL_N" -gt 0 ]; then
printf -- '%s numbered checks this run: #001…#%03d\n' "$D" "$GLOBAL_N"
printf -- '%s numbered checks this run: #001…#%03d%s\n' "$D" "$GLOBAL_N" "$N"
fi
if [ "${#BLOCKERS[@]}" -gt 0 ]; then
if [ "$blk_n" -gt 0 ]; then
if [ "${BOX:-0}" = "1" ]; then
printf -- '%s┌ BLOCKERS · pay/withdraw cannot finish ┐%s\n' "$BG_BLK" "$N"
else
printf -- '--- BLOCKERS (pay/withdraw cannot finish) ---\n'
printf -- '%s--- BLOCKERS (pay/withdraw cannot finish) ---%s\n' "$M" "$N"
fi
local b
for b in "${BLOCKERS[@]}"; do
printf -- ' %s•%s %s%s%s\n' "$M" "$N" "$W" "$b" "$N"
done
fi
if [ "${#ERRORS[@]}" -gt 0 ] && [ "${#BLOCKERS[@]}" -lt "${#ERRORS[@]}" ]; then
if [ "${#ERRORS[@]}" -gt 0 ] && [ "$blk_n" -lt "${#ERRORS[@]}" ]; then
if [ "${BOX:-0}" = "1" ]; then
printf -- '%s┌ ERRORS · failed checks ┐%s\n' "$BG_ERR" "$N"
else
printf -- '--- ERRORS (failed checks) ---\n'
printf -- '%s--- ERRORS (failed checks) ---%s\n' "$R" "$N"
fi
local e
for e in "${ERRORS[@]}"; do
@ -758,12 +759,46 @@ summary() {
printf -- ' %s•%s %s%s%s\n' "$R" "$N" "$W" "$e" "$N"
done
fi
printf -- '%stotals:%s %s%d OK%s' "$D" "$N" "$G" "$PASS_N" "$N"
# Coloured totals — same severity badges as check lines
if [ "${BOX:-0}" = "1" ]; then
printf -- '\n%s┌ SUMMARY ┐%s\n' "$BG_SEC" "$N"
printf -- ' %s┌ OK ┐%s %s%4d%s\n' "$BG_OK" "$N" "$G" "$PASS_N" "$N"
if [ "$FAIL_N" -gt 0 ]; then
printf -- ' %s┌ ERROR ┐%s %s%4d%s\n' "$BG_ERR" "$N" "$R" "$FAIL_N" "$N"
fi
if [ "$WARN_N" -gt 0 ]; then
printf -- ' %s┌ WARN ┐%s %s%4d%s\n' "$BG_WARN" "$N" "$Y" "$WARN_N" "$N"
fi
if [ "$INFO_N" -gt 0 ]; then
printf -- ' %s┌ INFO ┐%s %s%4d%s\n' "$BG_INFO" "$N" "$C" "$INFO_N" "$N"
fi
if [ "$blk_n" -gt 0 ]; then
printf -- ' %s┌ BLOCK ┐%s %s%4d%s\n' "$BG_BLK" "$N" "$M" "$blk_n" "$N"
fi
# one-line rollup (bold counts)
printf -- ' %s%s totals:%s %s%d OK%s' "$B" "$D" "$N" "$G" "$PASS_N" "$N"
[ "$FAIL_N" -gt 0 ] && printf -- ' · %s%d ERROR%s' "$R" "$FAIL_N" "$N"
[ "$WARN_N" -gt 0 ] && printf -- ' · %s%d WARN%s' "$Y" "$WARN_N" "$N"
[ "$INFO_N" -gt 0 ] && printf -- ' · %s%d INFO%s' "$C" "$INFO_N" "$N"
[ "$blk_n" -gt 0 ] && printf -- ' · %s%d BLOCKER%s' "$M" "$blk_n" "$N"
printf '\n'
# overall verdict
if [ "$FAIL_N" -eq 0 ] && [ "$blk_n" -eq 0 ] && [ "$WARN_N" -eq 0 ]; then
printf -- ' %s┌ OK ┐%s %sall clear%s\n' "$BG_OK" "$N" "$G" "$N"
elif [ "$FAIL_N" -eq 0 ] && [ "$blk_n" -eq 0 ]; then
printf -- ' %s┌ WARN ┐%s %swarnings only (no hard fail)%s\n' "$BG_WARN" "$N" "$Y" "$N"
else
printf -- ' %s┌ ERROR ┐%s %sfailed — see list above%s\n' "$BG_ERR" "$N" "$R" "$N"
fi
else
printf -- 'totals: %s%d OK%s' "$G" "$PASS_N" "$N"
[ "$FAIL_N" -gt 0 ] && printf -- ', %s%d ERROR%s' "$R" "$FAIL_N" "$N"
[ "$WARN_N" -gt 0 ] && printf -- ', %s%d WARN%s' "$Y" "$WARN_N" "$N"
[ "$INFO_N" -gt 0 ] && printf -- ', %s%d INFO%s' "$C" "$INFO_N" "$N"
[ "${#BLOCKERS[@]}" -gt 0 ] && printf -- ', %s%d BLOCKER%s' "$M" "${#BLOCKERS[@]}" "$N"
[ "$blk_n" -gt 0 ] && printf -- ', %s%d BLOCKER%s' "$M" "$blk_n" "$N"
printf '\n'
fi
[ "$FAIL_N" -eq 0 ]
}