diff options
| author | batsumaru <> | 2026-07-01 16:55:53 +0900 |
|---|---|---|
| committer | batsumaru <> | 2026-07-01 16:55:53 +0900 |
| commit | 15e09f49d28cb6312a95d304466bb79cb1a85c5d (patch) | |
| tree | 300238e4674f24822811026f30c6f41b1cd114eb /statuspage/checks | |
| parent | a034c6724381b172ba4b6d36357682c44f18b8de (diff) | |
Make the zpool check per-pool with capacity, scrub, and error status
Replace the single "all pools are healthy" summary line with one row
per pool (name, health, capacity) plus a scrub/errors row parsed from
`zpool status <pool>`. A pool that's never been scrubbed but has no
data errors still reports ok - lack of scrub history isn't itself a
failure, only actual reported errors are.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'statuspage/checks')
| -rwxr-xr-x | statuspage/checks/hw.sh | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/statuspage/checks/hw.sh b/statuspage/checks/hw.sh index bc0c669..259234d 100755 --- a/statuspage/checks/hw.sh +++ b/statuspage/checks/hw.sh @@ -1,6 +1,7 @@ #!/bin/sh # checks/hw.sh -# Hardware/host metrics: load avg, uptime, free mem, zroot usage, zpool health. +# Hardware/host metrics: load avg, uptime, free mem, zroot usage, and per +# pool health/capacity plus scrub/error status for every zpool on the box. set -eu DIR=$(dirname "$0") @@ -31,12 +32,24 @@ else fi json_line "hardware" "zroot usage" "$DISK" "$DISK_STATUS" -if ZPOOL=$(zpool status -x 2>&1); then - case "$ZPOOL" in - "all pools are healthy") ZPOOL_STATUS="ok" ;; - *) ZPOOL_STATUS="warn" ;; +for pool in $(zpool list -H -o name 2>/dev/null); do + HEALTH=$(zpool list -H -o health "$pool" 2>/dev/null) + CAP=$(zpool list -H -o capacity "$pool" 2>/dev/null) + case "$HEALTH" in + ONLINE) POOL_STATUS="ok" ;; + DEGRADED) POOL_STATUS="warn" ;; + *) POOL_STATUS="down" ;; esac -else - ZPOOL_STATUS="down" -fi -json_line "hardware" "zpool" "$ZPOOL" "$ZPOOL_STATUS" + json_line "hardware" "zpool $pool" "$HEALTH, ${CAP} used" "$POOL_STATUS" + + STATUS_OUT=$(zpool status "$pool" 2>/dev/null) || STATUS_OUT="" + SCAN=$(printf '%s\n' "$STATUS_OUT" | sed -n 's/^[[:space:]]*scan: //p') + ERRORS=$(printf '%s\n' "$STATUS_OUT" | sed -n 's/^[[:space:]]*errors: //p') + + case "$ERRORS" in + "No known data errors") ERR_STATUS="ok" ;; + "") ERR_STATUS="warn" ;; + *) ERR_STATUS="down" ;; + esac + json_line "hardware" "zpool $pool scrub" "${SCAN:-unknown}" "$ERR_STATUS" +done |
