diff --git a/scripts/taler-monitoring/README.md b/scripts/taler-monitoring/README.md index 878d106..9d5422f 100644 --- a/scripts/taler-monitoring/README.md +++ b/scripts/taler-monitoring/README.md @@ -56,15 +56,17 @@ Each check prints **global** and **grouped** ids: ```text ┌ OK ┐ #014 www.exchange-03 exchange /config · HTTP 200 ┌ WARN ┐ #015 www.stats-02 stats age soft · yellow badge (not red) -┌ PROG ┐ ████████░░░░ 42% 14/55 +┌ 42% ┐ ████████░░░░░░░░░░░░░░░░░░░░ 14/55 ``` - `#014` — run-wide counter (whole `./taler-monitoring.sh` invocation) - `www.exchange-03` — area.group-NN - **Colours (left badge + label):** - **OK** green · **INFO** blue/cyan · **WARN** yellow (never red) - - **ERROR** red · **BLOCKER** magenta · **PROG** cyan bar -- Progress: auto estimate per phase, or `PROGRESS_TOTAL=N` / `PROGRESS_OFF=1` + - **ERROR** red · **BLOCKER** magenta +- Progress: badge shows **percent** (not “PROG”); bar fills **left → right**; + `done/total` on the right. Estimate auto-grows if short. Override: + `PROGRESS_TOTAL=N` / `PROGRESS_OFF=1` - **QR (urls):** harvest `taler://` / `payto://` (+ app store `data-qr-url`) from landings and `demo-withdraw.json` / `auto-account.json` → validate form → `qrencode` PNG → `zbarimg` decode must match. Requires packages **`qrencode`** + **`zbar-tools`**. diff --git a/scripts/taler-monitoring/lib.sh b/scripts/taler-monitoring/lib.sh index 19764f8..645cf2e 100755 --- a/scripts/taler-monitoring/lib.sh +++ b/scripts/taler-monitoring/lib.sh @@ -367,7 +367,7 @@ koopa_ssh_python() { # WARN yellow badge · yellow label (never red) # ERROR red badge · red label # BLOCKER magenta badge· magenta label -# PROG cyan bar line +# progress cyan badge = " 42%" + bar fills left→right if [ "${NO_COLOR:-0}" = "1" ] || [ "${CLICOLOR:-1}" = "0" ]; then G= R= Y= C= M= D= W= B= N= BG_OK= BG_INFO= BG_WARN= BG_ERR= BG_BLK= BG_SEC= BG_PROG= @@ -520,38 +520,55 @@ _progress_rebalance() { fi } _progress_bar_line() { - local done="$1" total="$2" width=24 pct=0 filled empty i bar + # Format (grows left → right; badge = percent, not "PROG"): + # ┌ 42% ┐ ████████░░░░░░░░░░░░░░░░ 31/74 + local done="$1" total="$2" width=28 pct=0 filled empty i bar pct_lab # Defensive: never display done > total if [ "$total" -gt 0 ] && [ "$done" -gt "$total" ]; then total=$done fi if [ "$total" -gt 0 ]; then + # integer percent; while mid-run past a short estimate, cap display < 100% pct=$((done * 100 / total)) [ "$pct" -gt 100 ] && pct=100 - # While still running past an estimate, keep bar at most 99% until final rebalance if [ "$done" -lt "$total" ] && [ "$pct" -ge 100 ]; then pct=99 fi - filled=$((pct * width / 100)) + # fill cells from the left (progress moves rightward as filled grows) + filled=$((done * width / total)) [ "$filled" -gt "$width" ] && filled=$width + # show at least 1 block once any work done (unless 0%) + if [ "$done" -gt 0 ] && [ "$filled" -eq 0 ]; then + filled=1 + fi + # at 100% fill complete bar + if [ "$done" -ge "$total" ]; then + filled=$width + pct=100 + fi empty=$((width - filled)) bar="" i=0 while [ "$i" -lt "$filled" ]; do bar="${bar}█"; i=$((i + 1)); done i=0 while [ "$i" -lt "$empty" ]; do bar="${bar}░"; i=$((i + 1)); done + pct_lab=$(printf '%3d%%' "$pct") if [ "${BOX:-0}" = "1" ]; then - printf '%s┌ PROG ┐%s %s%s%s %s%3d%%%s %s%d/%d%s\n' \ - "$BG_PROG" "$N" "$C" "$bar" "$N" "$W" "$pct" "$N" "$D" "$done" "$total" "$N" + # badge = percent (clearer than "PROG"); bar grows ░→█ left to right + printf '%s┌%s┐%s %s%s%s %s%d/%d%s\n' \ + "$BG_PROG" "$pct_lab" "$N" \ + "$C" "$bar" "$N" \ + "$D" "$done" "$total" "$N" else - printf -- '%s[ PROG ]%s [%s] %3d%% %d/%d\n' "$C" "$N" "$bar" "$pct" "$done" "$total" + printf -- '%s%4s%s %s %d/%d\n' \ + "$C" "$pct_lab" "$N" "$bar" "$done" "$total" fi else if [ "${BOX:-0}" = "1" ]; then - printf '%s┌ PROG ┐%s %sdone=%d%s (total unknown — set PROGRESS_TOTAL=)\n' \ + printf '%s┌ … ┐%s %sdone=%d%s (set PROGRESS_TOTAL= for %%)\n' \ "$BG_PROG" "$N" "$D" "$done" "$N" else - printf -- '%s[ PROG ]%s done=%d (total unknown)\n' "$C" "$N" "$done" + printf -- '%sdone=%d%s (set PROGRESS_TOTAL= for %%)\n' "$D" "$done" "$N" fi fi }