From e82ee9a70b9e50f50b93cd87046f2c5a222bc0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A2ni=20Marques?= Date: Fri, 17 Jul 2026 19:03:49 +0200 Subject: [PATCH] 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). --- scripts/taler-monitoring/lib.sh | 61 ++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/scripts/taler-monitoring/lib.sh b/scripts/taler-monitoring/lib.sh index 645cf2e..c3cd2b2 100755 --- a/scripts/taler-monitoring/lib.sh +++ b/scripts/taler-monitoring/lib.sh @@ -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,37 +734,71 @@ 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" + 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 case "$e" in BLOCKER*) continue ;; esac - printf -- '%s •%s %s%s%s\n' "$R" "$N" "$W" "$e" "$N" + 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" - [ "$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" - printf '\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" + [ "$blk_n" -gt 0 ] && printf -- ', %s%d BLOCKER%s' "$M" "$blk_n" "$N" + printf '\n' + fi [ "$FAIL_N" -eq 0 ] }