feat(oam): codify garage-pdu-relay snmpd extend + timeout hardening [#733]

Deployed manually on tsys-librenms 2026-09-02 (founder relay ruling);
codified same-day rule. snmpget -t2 -r1 so a dark PDU answers in ~2s.
Deployed target: tsys-librenms:/usr/local/bin/garage-pdu-relay.

Detail: https://projects.knownelement.com/issues/733
This commit is contained in:
2026-09-03 12:55:31 -05:00
parent d3b9099d5f
commit e27e3a06b8
2 changed files with 99 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# garage-pdu-relay: expose APC AP7830 metered output current via snmpd extend.
#
# Relay pattern (founder ruling 2026-09-02): the garage PDU speaks SNMPv1
# only, walks die on its old AOS, and its ACL admits the LibreNMS VM vantage.
# This relay runs ON tsys-librenms; HA polls the relay via the fleet snmpd
# extend (same rails as drac-extend). Output: "output_amps <x.y>".
#
# Deploy target: tsys-librenms:/usr/local/bin/garage-pdu-relay ONLY (relay
# host — not a per-host agent). snmpd.conf line on the relay host:
# extend garagepdu /usr/local/bin/garage-pdu-relay
# snmpd ACL must admit the pfv-bms LAN + Tailscale IPs as query sources
# (rocommunity kn3lmgmt 192.168.3.12 / 100.67.108.125 as of 2026-09-03).
#
# Codified 2026-09-03 [#733]: was deployed manually 2026-09-02; hardened
# with explicit snmpget timeout/retry so a dark PDU answers in ~2s instead
# of ~6s and cannot pile up long-running children under HA's poll cadence.
set -euo pipefail
PDU_HOST="${PDU_HOST:-pfv-garage-pdu-1.knel.net}"
COMMUNITY="${PDU_COMMUNITY:-kn3lmgmt}"
OID=".1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.1"
raw=$(snmpget -v1 -c "$COMMUNITY" -t 2 -r 1 -On -Ov "$PDU_HOST" "$OID" 2>/dev/null \
| grep -oE '[0-9]+$') || true
if [ -z "${raw:-}" ]; then
echo "output_amps unavailable"
exit 0
fi
awk -v t="$raw" 'BEGIN { printf "output_amps %.1f\n", t/10 }'