From 15e09f49d28cb6312a95d304466bb79cb1a85c5d Mon Sep 17 00:00:00 2001 From: batsumaru <> Date: Wed, 1 Jul 2026 16:55:53 +0900 Subject: 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 `. 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 --- statuspage/checks/hw.sh | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'statuspage/checks/hw.sh') 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 -- cgit v1.3