feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
#!/bin/sh
# rosenpass-metrics.sh — emit Rosenpass health metrics for node-exporter's
# textfile collector.
#
2026-12-03 02:43:17 -05:00
# Installed on rpi and siriussec (the two ends of Link A: rpi wg0 10.10.0.1 <->
# siriussec wg0 10.10.0.2), run every 60 s by rosenpass-metrics.timer as root.
# See README.md in this directory.
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
#
# Why a host script: kube-prometheus-stack-prometheus-node-exporter is
# distroless and ships without --collector.textfile.directory (and without the
# dbus plumbing --collector.systemd needs), so nothing inside the cluster can
# observe a host systemd unit. This writes a textfile that the DaemonSet's
# textfile collector then serves on :9100/metrics.
#
# Signals:
# rosenpass_unit_active{node}
# 1 when `systemctl is-active rosenpass.service`
# says active, else 0.
# rosenpass_psk_rotation_age_seconds{node,interface}
2026-12-03 02:43:17 -05:00
# seconds since that interface's preshared-key set
# last changed. Rotation runs about every two minutes.
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
# rosenpass_psk_rotation_last_change_timestamp_seconds{node,interface}
# unix timestamp of that last observed change.
2026-12-03 02:52:58 -05:00
# rosenpass_upnp_mapping_present{node}
# 1/0 state that rosenpass-upnp.sh stamped on its
# last run (Link B's only inbound path on the Pi).
# Only emitted where that unit runs: no state file,
# no series, so siriussec does not advertise it.
# rosenpass_upnp_last_check_timestamp_seconds{node}
# unix mtime of that state file, so a stopped
# rosenpass-upnp.timer reads as stale rather than as
# a flat healthy 1.
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
#
2026-12-03 02:43:17 -05:00
# Interfaces are emitted independently: wg0 is Link A (rpi <-> siriussec) and
# wg-remote is Link B (rpi <-> linode, through a permanent UPnP mapping on a
# router with no admin access). Link B stalls silently if the Pi's residential
# public address moves, so it needs its own series — hashing only wg0 leaves
# Link B unobserved.
#
# The preshared key is NEVER printed, logged or stored: each interface's key
# listing is piped straight into sha256sum and only the hex digest is kept, in a
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
# root-only state file. Do not add an `echo` of the listing while debugging.
#
# Deliberately independent of rosenpass.service: this script must keep
# reporting (unit_active=0, age growing) while the thing it watches is dead.
set -eu
NODE = $( hostname -s)
2026-12-03 02:43:17 -05:00
# Interfaces rosenpass manages on this host. One absent here is skipped, so the
# same file is correct on rpi (wg0 + wg-remote) and siriussec (wg0 only).
IFACES = "wg0 wg-remote"
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
UNIT = rosenpass.service
STATE_DIR = /var/lib/rosenpass-exporter
OUT_DIR = /var/lib/node-exporter/textfile
OUT_FILE = $OUT_DIR /rosenpass.prom
# 0644 so the node-exporter container (nobody/65534) can read the file and the
# directory stays traversable.
umask 022
mkdir -p " $STATE_DIR " " $OUT_DIR "
now = $( date +%s)
# --- 1. unit state -----------------------------------------------------------
active = 0
if [ " $( systemctl is-active " $UNIT " 2>/dev/null || true ) " = "active" ] ; then
active = 1
fi
2026-12-03 02:52:58 -05:00
# --- 2. UPnP mapping state (Link B inbound path) -----------------------------
# rosenpass-upnp.sh stamps 1/0 into /run on each of its 15-min runs. This timer
# must NOT call upnpc itself: that would poll the IGD 1440x/day and put the
# fragile component in the hot path. No state file means this host does not run
# that unit (siriussec), so emit nothing there.
UPNP_STATE = /run/rosenpass-upnp.present
upnp = ""
upnp_ts = ""
if [ -r " $UPNP_STATE " ] ; then
upnp = $( head -n 1 " $UPNP_STATE " 2>/dev/null | tr -d '[:space:]' )
case " $upnp " in
0 | 1) upnp_ts = $( stat -c %Y " $UPNP_STATE " 2>/dev/null || echo " $now " ) ; ;
*) upnp = "" ; ;
esac
fi
# --- 3. PSK rotation, per interface -----------------------------------------
2026-12-03 02:43:17 -05:00
# `wg show ... preshared-keys` fails (and prints nothing) when the interface is
# absent; command substitution would otherwise hash an empty string, which looks
# like a change on the first poll after the interface returns. Only hash real
# output, and keep one state file per interface so a Link B rotation is never
# recorded as a Link A one.
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
tmp = " $OUT_FILE . $$ "
{
printf '# HELP rosenpass_unit_active rosenpass.service is active (1) or not (0).\n'
printf '# TYPE rosenpass_unit_active gauge\n'
printf 'rosenpass_unit_active{node="%s"} %s\n' " $NODE " " $active "
2026-12-03 02:52:58 -05:00
if [ -n " $upnp " ] ; then
printf '# HELP rosenpass_upnp_mapping_present The Link B UPnP mapping (UDP 9999 -> rpi) is present (1) or missing (0), as of the last rosenpass-upnp.sh run.\n'
printf '# TYPE rosenpass_upnp_mapping_present gauge\n'
printf 'rosenpass_upnp_mapping_present{node="%s"} %s\n' " $NODE " " $upnp "
printf '# HELP rosenpass_upnp_last_check_timestamp_seconds Unix timestamp of the last rosenpass-upnp.sh run that wrote the state file.\n'
printf '# TYPE rosenpass_upnp_last_check_timestamp_seconds gauge\n'
printf 'rosenpass_upnp_last_check_timestamp_seconds{node="%s"} %s\n' " $NODE " " $upnp_ts "
fi
2026-12-03 02:43:17 -05:00
printf '# HELP rosenpass_psk_rotation_age_seconds Seconds since that interface preshared-key set last changed.\n'
printf '# TYPE rosenpass_psk_rotation_age_seconds gauge\n'
printf '# HELP rosenpass_psk_rotation_last_change_timestamp_seconds Unix timestamp of the last observed preshared-key change on that interface.\n'
printf '# TYPE rosenpass_psk_rotation_last_change_timestamp_seconds gauge\n'
for IFACE in $IFACES ; do
psk_list = $( wg show " $IFACE " preshared-keys 2>/dev/null || true )
[ -n " $psk_list " ] || continue
STATE_FILE = $STATE_DIR /last-hash-$IFACE
last_hash = ""
last_change = ""
if [ -f " $STATE_FILE " ] ; then
last_hash = $( sed -n '1p' " $STATE_FILE " )
last_change = $( sed -n '2p' " $STATE_FILE " )
fi
hash_now = $( printf '%s' " $psk_list " | sha256sum | awk '{print $1}' )
if [ " $hash_now " != " $last_hash " ] ; then
# First observation or an actual rotation: stamp it.
last_change = $now
printf '%s\n%s\n' " $hash_now " " $last_change " > " $STATE_FILE .tmp "
mv " $STATE_FILE .tmp " " $STATE_FILE "
fi
[ -n " $last_change " ] || continue
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
age = $(( now - last_change))
[ " $age " -ge 0 ] || age = 0
printf 'rosenpass_psk_rotation_age_seconds{node="%s",interface="%s"} %s\n' " $NODE " " $IFACE " " $age "
printf 'rosenpass_psk_rotation_last_change_timestamp_seconds{node="%s",interface="%s"} %s\n' " $NODE " " $IFACE " " $last_change "
2026-12-03 02:43:17 -05:00
done
feat(monitoring): alert on Rosenpass unit state and stalled PSK rotation
Rosenpass rotates the Link A preshared key (rpi wg0 10.10.0.1 <->
siriussec wg0 10.10.0.2) about every two minutes, but WireGuard keeps
using the last key it received: a dead or wedged exchange leaves the
tunnel up and silently non-post-quantum, with no alerting signal.
node-exporter here is distroless without the textfile collector (and
without the dbus plumbing --collector.systemd needs), so observe the
host directly:
- infrastructure/networking/rosenpass/: POSIX sh script run by a 60 s
systemd timer on rpi and siriussec that writes
/var/lib/node-exporter/textfile/rosenpass.prom. It exports
rosenpass_unit_active, rosenpass_psk_rotation_age_seconds and
rosenpass_psk_rotation_last_change_timestamp_seconds; the PSK listing
is only ever sha256'd, never logged or persisted.
- values.yaml: enable --collector.textfile.directory and mount the
hostPath (DirectoryOrCreate, so linode's node-exporter still starts).
extraArgs replaces the subchart defaults, so the two filesystem
exclusions are repeated verbatim.
- rosenpass.yaml: RosenpassDown (5 m) and RosenpassPskRotationStalled
(age > 900 s, 10 m), both warning, both with absent() arms so a
missing series alerts instead of reading as healthy.
Host units are installed out of band (see the directory README); the
GitOps side needs a merge before Prometheus loads the rules.
2026-12-03 02:16:30 -05:00
} > " $tmp "
chmod 0644 " $tmp "
mv " $tmp " " $OUT_FILE "