From 358106287b28bffa8505b67fe623f77a3fbceae3 Mon Sep 17 00:00:00 2001 From: batsumaru <> Date: Wed, 1 Jul 2026 16:25:42 +0900 Subject: Auto-discover jails and add WireGuard peer info to status page Replace the per-jail check scripts with checks/jails.sh, which lists running jails via jls and resolves each one's IPv4 (falling back to jexec+ifconfig for VNET jails, which don't set the ip4.addr jail parameter). New jails now show up without adding a script; the trade-off is a stopped jail just disappears rather than showing down, since jls only lists what's running. checks/wireguard.sh now also reports each configured peer's allowed-IP and time since last handshake, parsed from `wg show wg0 dump`. Co-Authored-By: Claude Sonnet 5 --- statuspage/checks/wireguard.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'statuspage/checks/wireguard.sh') diff --git a/statuspage/checks/wireguard.sh b/statuspage/checks/wireguard.sh index 3a899e5..2928e3e 100755 --- a/statuspage/checks/wireguard.sh +++ b/statuspage/checks/wireguard.sh @@ -1,6 +1,7 @@ #!/bin/sh # checks/wireguard.sh # wg0 interface: at least one recent handshake means the tunnel is alive. +# Also lists each configured peer with time since its last handshake. set -eu DIR=$(dirname "$0") @@ -8,3 +9,38 @@ DIR=$(dirname "$0") STATUS=$(wg_status wg0) json_line "host services" "wireguard (wg0)" "" "$STATUS" + +NOW=$(date +%s) +TAB=$(printf '\t') + +wg show wg0 dump 2>/dev/null | tail -n +2 | while IFS="$TAB" read -r pubkey psk endpoint allowedips handshake rx tx keepalive; do + [ -n "$pubkey" ] || continue + peer_id=$(printf '%s' "$pubkey" | cut -c1-8) + label="peer $peer_id ($allowedips)" + + if [ "$handshake" = "0" ]; then + json_line "wireguard peers" "$label" "never" "down" + continue + fi + + age=$((NOW - handshake)) + if [ "$age" -lt 180 ]; then + pstatus="ok" + elif [ "$age" -lt 600 ]; then + pstatus="warn" + else + pstatus="down" + fi + + if [ "$age" -lt 60 ]; then + rel="${age}s ago" + elif [ "$age" -lt 3600 ]; then + rel="$((age / 60))m ago" + elif [ "$age" -lt 86400 ]; then + rel="$((age / 3600))h ago" + else + rel="$((age / 86400))d ago" + fi + + json_line "wireguard peers" "$label" "$rel" "$pstatus" +done -- cgit v1.3