agent: add nordlynx VPN status to metrics

Detects nordlynx WireGuard interface on hosts that run NordVPN and
includes active/inactive status in the metrics payload. JARVIS alerts.php
will generate a critical alert and auto-restart nordvpnd if it goes down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-14 00:09:19 +00:00
parent 205fc37c12
commit 8d64320749
+17 -1
View File
@@ -265,11 +265,23 @@ def get_load() -> list:
except Exception:
return [0, 0, 0]
def get_nordvpn_status() -> dict | None:
"""Check nordlynx WireGuard interface. Returns None if nordlynx not present on this host."""
try:
r = subprocess.run(["ip", "link", "show", "nordlynx"],
capture_output=True, text=True, timeout=3)
if r.returncode != 0:
return None
active = "UP,LOWER_UP" in r.stdout or "state UP" in r.stdout
return {"active": active, "interface": "nordlynx"}
except Exception:
return None
def collect_metrics(cfg: dict) -> dict:
# First reading for CPU delta
get_cpu_percent()
time.sleep(1)
return {
metrics = {
"hostname": cfg.get("hostname", socket.gethostname()),
"cpu_percent": get_cpu_percent(),
"memory": get_memory(),
@@ -280,6 +292,10 @@ def collect_metrics(cfg: dict) -> dict:
"platform": platform.system(),
"timestamp": datetime.utcnow().isoformat() + "Z",
}
nordvpn = get_nordvpn_status()
if nordvpn is not None:
metrics["nordvpn"] = nordvpn
return metrics
# ── Proxmox metrics ───────────────────────────────────────────────────────────