From 8d643207496fcc1b19193b09bb96e39686e83dfc Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Sun, 14 Jun 2026 00:09:19 +0000 Subject: [PATCH] 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 --- agent/jarvis-agent.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/agent/jarvis-agent.py b/agent/jarvis-agent.py index 53bbef7..d01cc2c 100755 --- a/agent/jarvis-agent.py +++ b/agent/jarvis-agent.py @@ -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 ───────────────────────────────────────────────────────────