mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
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:
+17
-1
@@ -265,11 +265,23 @@ def get_load() -> list:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return [0, 0, 0]
|
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:
|
def collect_metrics(cfg: dict) -> dict:
|
||||||
# First reading for CPU delta
|
# First reading for CPU delta
|
||||||
get_cpu_percent()
|
get_cpu_percent()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return {
|
metrics = {
|
||||||
"hostname": cfg.get("hostname", socket.gethostname()),
|
"hostname": cfg.get("hostname", socket.gethostname()),
|
||||||
"cpu_percent": get_cpu_percent(),
|
"cpu_percent": get_cpu_percent(),
|
||||||
"memory": get_memory(),
|
"memory": get_memory(),
|
||||||
@@ -280,6 +292,10 @@ def collect_metrics(cfg: dict) -> dict:
|
|||||||
"platform": platform.system(),
|
"platform": platform.system(),
|
||||||
"timestamp": datetime.utcnow().isoformat() + "Z",
|
"timestamp": datetime.utcnow().isoformat() + "Z",
|
||||||
}
|
}
|
||||||
|
nordvpn = get_nordvpn_status()
|
||||||
|
if nordvpn is not None:
|
||||||
|
metrics["nordvpn"] = nordvpn
|
||||||
|
return metrics
|
||||||
|
|
||||||
# ── Proxmox metrics ───────────────────────────────────────────────────────────
|
# ── Proxmox metrics ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user