From 45f7fb33d96350798bfcc16877be152e2fa308bf Mon Sep 17 00:00:00 2001 From: batsumaru <> Date: Wed, 1 Jul 2026 17:08:29 +0900 Subject: Fix uptime to include hours/minutes, add a purple/gold theme hw.sh's uptime was parsed from `uptime`'s text output, which cut off at the first comma - dropping the H:MM part entirely. It also never actually rolled over to months/years for long uptimes (FreeBSD's uptime just keeps growing the day count). Replaced with a direct `sysctl kern.boottime` computation for a fully deterministic "Nd Hh Mm" format. Caught a real bug along the way: the first attempt at the sed extraction grabbed `usec` instead of `sec`, since "usec" contains "sec" as a substring and the pattern wasn't anchored tightly enough. render.sh's palette now uses purple/lavender for headings and borders and a gold accent (title underline, value-column text), taking cues from reference character art. The green/yellow/red/gray status squares are untouched - they carry semantic meaning the color scheme shouldn't interfere with. Co-Authored-By: Claude Sonnet 5 --- statuspage/checks/hw.sh | 8 ++++++-- statuspage/render.sh | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/statuspage/checks/hw.sh b/statuspage/checks/hw.sh index 259234d..54c4718 100755 --- a/statuspage/checks/hw.sh +++ b/statuspage/checks/hw.sh @@ -10,8 +10,12 @@ DIR=$(dirname "$0") LOAD=$(sysctl -n vm.loadavg | tr -d '{}' | sed 's/^ *//;s/ *$//') json_line "hardware" "load avg" "$LOAD" "ok" -UPTIME=$(uptime | sed 's/.*up //;s/,.*load.*//') -json_line "hardware" "uptime" "$UPTIME" "ok" +BOOT=$(sysctl -n kern.boottime | sed -n 's/{ sec = \([0-9]*\).*/\1/p') +SECS=$(($(date +%s) - BOOT)) +UP_D=$((SECS / 86400)) +UP_H=$(((SECS % 86400) / 3600)) +UP_M=$(((SECS % 3600) / 60)) +json_line "hardware" "uptime" "${UP_D}d ${UP_H}h ${UP_M}m" "ok" MEM_FREE=$(sysctl -n vm.stats.vm.v_free_count) MEM_PAGE=$(sysctl -n hw.pagesize) diff --git a/statuspage/render.sh b/statuspage/render.sh index a7f23c4..301b85d 100755 --- a/statuspage/render.sh +++ b/statuspage/render.sh @@ -120,19 +120,20 @@ END { print "" htmlesc(host) " status" print "" print "" print "" print "" @@ -147,7 +148,7 @@ END { print "

" htmlesc(sect) "

" print "" for (j = 1; j <= count[sect]; j++) { - valcell = (V[sect, j] == "") ? "" : "" + valcell = (V[sect, j] == "") ? "" : "" print "" valcell "" } print "
" htmlesc(V[sect, j]) "" htmlesc(V[sect, j]) "
" htmlesc(L[sect, j]) "
" -- cgit v1.3