monitoring: progress badge shows percent, bar grows right
Replace confusing PROG label with " 42%"; fill █ from the left; done/total stays on the right.
This commit is contained in:
parent
736f1cde88
commit
6a6300f4ab
2 changed files with 31 additions and 12 deletions
|
|
@ -56,15 +56,17 @@ Each check prints **global** and **grouped** ids:
|
||||||
```text
|
```text
|
||||||
┌ OK ┐ #014 www.exchange-03 exchange /config · HTTP 200
|
┌ OK ┐ #014 www.exchange-03 exchange /config · HTTP 200
|
||||||
┌ WARN ┐ #015 www.stats-02 stats age soft · yellow badge (not red)
|
┌ 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)
|
- `#014` — run-wide counter (whole `./taler-monitoring.sh` invocation)
|
||||||
- `www.exchange-03` — area.group-NN
|
- `www.exchange-03` — area.group-NN
|
||||||
- **Colours (left badge + label):**
|
- **Colours (left badge + label):**
|
||||||
- **OK** green · **INFO** blue/cyan · **WARN** yellow (never red)
|
- **OK** green · **INFO** blue/cyan · **WARN** yellow (never red)
|
||||||
- **ERROR** red · **BLOCKER** magenta · **PROG** cyan bar
|
- **ERROR** red · **BLOCKER** magenta
|
||||||
- Progress: auto estimate per phase, or `PROGRESS_TOTAL=N` / `PROGRESS_OFF=1`
|
- 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
|
- **QR (urls):** harvest `taler://` / `payto://` (+ app store `data-qr-url`) from landings and
|
||||||
`demo-withdraw.json` / `auto-account.json` → validate form → `qrencode` PNG → `zbarimg`
|
`demo-withdraw.json` / `auto-account.json` → validate form → `qrencode` PNG → `zbarimg`
|
||||||
decode must match. Requires packages **`qrencode`** + **`zbar-tools`**.
|
decode must match. Requires packages **`qrencode`** + **`zbar-tools`**.
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ koopa_ssh_python() {
|
||||||
# WARN yellow badge · yellow label (never red)
|
# WARN yellow badge · yellow label (never red)
|
||||||
# ERROR red badge · red label
|
# ERROR red badge · red label
|
||||||
# BLOCKER magenta badge· magenta 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
|
if [ "${NO_COLOR:-0}" = "1" ] || [ "${CLICOLOR:-1}" = "0" ]; then
|
||||||
G= R= Y= C= M= D= W= B= N=
|
G= R= Y= C= M= D= W= B= N=
|
||||||
BG_OK= BG_INFO= BG_WARN= BG_ERR= BG_BLK= BG_SEC= BG_PROG=
|
BG_OK= BG_INFO= BG_WARN= BG_ERR= BG_BLK= BG_SEC= BG_PROG=
|
||||||
|
|
@ -520,38 +520,55 @@ _progress_rebalance() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
_progress_bar_line() {
|
_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
|
# Defensive: never display done > total
|
||||||
if [ "$total" -gt 0 ] && [ "$done" -gt "$total" ]; then
|
if [ "$total" -gt 0 ] && [ "$done" -gt "$total" ]; then
|
||||||
total=$done
|
total=$done
|
||||||
fi
|
fi
|
||||||
if [ "$total" -gt 0 ]; then
|
if [ "$total" -gt 0 ]; then
|
||||||
|
# integer percent; while mid-run past a short estimate, cap display < 100%
|
||||||
pct=$((done * 100 / total))
|
pct=$((done * 100 / total))
|
||||||
[ "$pct" -gt 100 ] && pct=100
|
[ "$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
|
if [ "$done" -lt "$total" ] && [ "$pct" -ge 100 ]; then
|
||||||
pct=99
|
pct=99
|
||||||
fi
|
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
|
[ "$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))
|
empty=$((width - filled))
|
||||||
bar=""
|
bar=""
|
||||||
i=0
|
i=0
|
||||||
while [ "$i" -lt "$filled" ]; do bar="${bar}█"; i=$((i + 1)); done
|
while [ "$i" -lt "$filled" ]; do bar="${bar}█"; i=$((i + 1)); done
|
||||||
i=0
|
i=0
|
||||||
while [ "$i" -lt "$empty" ]; do bar="${bar}░"; i=$((i + 1)); done
|
while [ "$i" -lt "$empty" ]; do bar="${bar}░"; i=$((i + 1)); done
|
||||||
|
pct_lab=$(printf '%3d%%' "$pct")
|
||||||
if [ "${BOX:-0}" = "1" ]; then
|
if [ "${BOX:-0}" = "1" ]; then
|
||||||
printf '%s┌ PROG ┐%s %s%s%s %s%3d%%%s %s%d/%d%s\n' \
|
# badge = percent (clearer than "PROG"); bar grows ░→█ left to right
|
||||||
"$BG_PROG" "$N" "$C" "$bar" "$N" "$W" "$pct" "$N" "$D" "$done" "$total" "$N"
|
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
|
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
|
fi
|
||||||
else
|
else
|
||||||
if [ "${BOX:-0}" = "1" ]; then
|
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"
|
"$BG_PROG" "$N" "$D" "$done" "$N"
|
||||||
else
|
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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue