feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
41
scripts/check_down_monitors.py
Normal file
41
scripts/check_down_monitors.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import requests
|
||||
import json
|
||||
import urllib3
|
||||
urllib3.disable_warnings()
|
||||
|
||||
try:
|
||||
r = requests.get("http://140.44.4.28:448/api/status-page/heartbeat/default", verify=False, timeout=10)
|
||||
data = r.json()
|
||||
heartbeats = data.get("heartbeatList", {})
|
||||
down = []
|
||||
up = []
|
||||
|
||||
# Also fetch status page monitor list to map IDs to names
|
||||
r_sp = requests.get("http://140.44.4.28:448/api/status-page/default", verify=False, timeout=10)
|
||||
sp_data = r_sp.json()
|
||||
|
||||
id_to_name = {}
|
||||
for group in sp_data.get("publicGroupList", []):
|
||||
for m in group.get("monitorList", []):
|
||||
id_to_name[str(m.get("id"))] = m.get("name")
|
||||
|
||||
for mid, beats in heartbeats.items():
|
||||
name = id_to_name.get(str(mid), f"Monitor #{mid}")
|
||||
if beats:
|
||||
last = beats[-1]
|
||||
if last.get("status") == 1:
|
||||
up.append((name, last.get("ping")))
|
||||
else:
|
||||
down.append((name, last.get("msg")))
|
||||
|
||||
print(f"Total Monitors: {len(heartbeats)}")
|
||||
print(f"Up: {len(up)} | Down: {len(down)}")
|
||||
if down:
|
||||
print("\nDown Monitors:")
|
||||
for name, msg in down:
|
||||
print(f" ❌ {name}: {msg}")
|
||||
else:
|
||||
print("\nAll monitors are UP! 🎉")
|
||||
except Exception as e:
|
||||
print("Error:", e)
|
||||
|
||||
Reference in New Issue
Block a user