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 ───────────────────────────────────────────────────────────