diff options
| author | batsumaru <> | 2026-07-01 15:38:51 +0900 |
|---|---|---|
| committer | batsumaru <> | 2026-07-01 15:38:51 +0900 |
| commit | dfec6df2fb876fadb20d24a5bd8f4b4400a0f659 (patch) | |
| tree | 3fc126f5bbaeef31b3a7a6d3e2afda968473c9b9 /statuspage/checks | |
Split monolithic status check.sh into modular check scripts
Replace the single-file prototype with independently-addable check
scripts (checks/*.sh) that each emit JSONL rows, a shared helper lib,
and one orchestrator/renderer (render.sh) that groups rows by section
and writes the static status page. A broken check script now shows up
as a down/warn row instead of crashing the whole render.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'statuspage/checks')
| -rw-r--r-- | statuspage/checks/caddy.sh | 10 | ||||
| -rw-r--r-- | statuspage/checks/ddclient.sh | 10 | ||||
| -rw-r--r-- | statuspage/checks/hw.sh | 42 | ||||
| -rw-r--r-- | statuspage/checks/jail-cgit.sh | 13 | ||||
| -rw-r--r-- | statuspage/checks/jail-www.sh | 13 | ||||
| -rw-r--r-- | statuspage/checks/wireguard.sh | 10 |
6 files changed, 98 insertions, 0 deletions
diff --git a/statuspage/checks/caddy.sh b/statuspage/checks/caddy.sh new file mode 100644 index 0000000..9e88a00 --- /dev/null +++ b/statuspage/checks/caddy.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# checks/caddy.sh +# Host reverse proxy service. +set -eu + +DIR=$(dirname "$0") +. "$DIR/../lib/common.sh" + +STATUS=$(svc_status caddy) +json_line "host services" "caddy" "" "$STATUS" diff --git a/statuspage/checks/ddclient.sh b/statuspage/checks/ddclient.sh new file mode 100644 index 0000000..361d252 --- /dev/null +++ b/statuspage/checks/ddclient.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# checks/ddclient.sh +# Dynamic DNS updater service. +set -eu + +DIR=$(dirname "$0") +. "$DIR/../lib/common.sh" + +STATUS=$(svc_status ddclient) +json_line "host services" "ddclient" "" "$STATUS" diff --git a/statuspage/checks/hw.sh b/statuspage/checks/hw.sh new file mode 100644 index 0000000..bc0c669 --- /dev/null +++ b/statuspage/checks/hw.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# checks/hw.sh +# Hardware/host metrics: load avg, uptime, free mem, zroot usage, zpool health. +set -eu + +DIR=$(dirname "$0") +. "$DIR/../lib/common.sh" + +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" + +MEM_FREE=$(sysctl -n vm.stats.vm.v_free_count) +MEM_PAGE=$(sysctl -n hw.pagesize) +MEM_FREE_MB=$((MEM_FREE * MEM_PAGE / 1024 / 1024)) +json_line "hardware" "free mem" "${MEM_FREE_MB} MB" "ok" + +DISK=$(df -h /zroot 2>/dev/null | awk 'NR==2{print $5}') +DISK_PCT=${DISK%\%} +if [ -z "$DISK_PCT" ]; then + DISK_STATUS="warn" + DISK="unknown" +elif [ "$DISK_PCT" -ge 90 ]; then + DISK_STATUS="down" +elif [ "$DISK_PCT" -ge 75 ]; then + DISK_STATUS="warn" +else + DISK_STATUS="ok" +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" ;; + esac +else + ZPOOL_STATUS="down" +fi +json_line "hardware" "zpool" "$ZPOOL" "$ZPOOL_STATUS" diff --git a/statuspage/checks/jail-cgit.sh b/statuspage/checks/jail-cgit.sh new file mode 100644 index 0000000..aabeacf --- /dev/null +++ b/statuspage/checks/jail-cgit.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# checks/jail-cgit.sh +# cgit VNET jail: jail-up check, then nginx-inside-jail http check. +set -eu + +DIR=$(dirname "$0") +. "$DIR/../lib/common.sh" + +JAIL_STATUS=$(jail_status cgit) +json_line "jails" "cgit jail" "" "$JAIL_STATUS" + +HTTP_STATUS=$(port_check 192.168.100.10 80) +json_line "jails" " -> http :80" "" "$HTTP_STATUS" diff --git a/statuspage/checks/jail-www.sh b/statuspage/checks/jail-www.sh new file mode 100644 index 0000000..7b6274e --- /dev/null +++ b/statuspage/checks/jail-www.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# checks/jail-www.sh +# www VNET jail: jail-up check, then nginx-inside-jail http check. +set -eu + +DIR=$(dirname "$0") +. "$DIR/../lib/common.sh" + +JAIL_STATUS=$(jail_status www) +json_line "jails" "www jail" "" "$JAIL_STATUS" + +HTTP_STATUS=$(port_check 192.168.100.20 80) +json_line "jails" " -> http :80" "" "$HTTP_STATUS" diff --git a/statuspage/checks/wireguard.sh b/statuspage/checks/wireguard.sh new file mode 100644 index 0000000..3a899e5 --- /dev/null +++ b/statuspage/checks/wireguard.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# checks/wireguard.sh +# wg0 interface: at least one recent handshake means the tunnel is alive. +set -eu + +DIR=$(dirname "$0") +. "$DIR/../lib/common.sh" + +STATUS=$(wg_status wg0) +json_line "host services" "wireguard (wg0)" "" "$STATUS" |
