mirror of
https://github.com/ced4568/ceds-noc.git
synced 2026-08-12 21:04:02 +00:00
Upgrade NOC badge to severity-based alerts (V6)
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"label": "Ced's NOC",
|
||||
"message": "All Systems Online | 8/8 online | 0 offline",
|
||||
"message": "Healthy | 8/8 online | 0 offline",
|
||||
"color": "brightgreen"
|
||||
}
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"nocName": "Ced's NOC",
|
||||
"status": "All Systems Online",
|
||||
"lastUpdated": "2026-04-26 17:50:50",
|
||||
"lastUpdated": "2026-04-26 21:13:17",
|
||||
"summary": {
|
||||
"nodes": "12+",
|
||||
"services": "8/8",
|
||||
@@ -19,8 +19,8 @@
|
||||
"severity": "Healthy",
|
||||
"layer": "Core Infrastructure",
|
||||
"label": "Hypervisor",
|
||||
"latency": "4 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"latency": "17 ms",
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "TrueNAS",
|
||||
@@ -30,8 +30,8 @@
|
||||
"severity": "Healthy",
|
||||
"layer": "Storage",
|
||||
"label": "NAS",
|
||||
"latency": "0 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"latency": "15 ms",
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "Nginx Proxy Manager",
|
||||
@@ -41,8 +41,8 @@
|
||||
"severity": "Healthy",
|
||||
"layer": "Access Layer",
|
||||
"label": "Proxy",
|
||||
"latency": "3 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"latency": "0 ms",
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "Dashy",
|
||||
@@ -52,8 +52,8 @@
|
||||
"severity": "Healthy",
|
||||
"layer": "Dashboard",
|
||||
"label": "Portal",
|
||||
"latency": "11 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"latency": "0 ms",
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "Jellyfin",
|
||||
@@ -64,7 +64,7 @@
|
||||
"layer": "Application Service",
|
||||
"label": "App",
|
||||
"latency": "0 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "K3s API",
|
||||
@@ -75,18 +75,18 @@
|
||||
"layer": "Compute Cluster",
|
||||
"label": "Cluster",
|
||||
"latency": "0 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "APRS Home iGate",
|
||||
"type": "RF Edge Gateway",
|
||||
"address": "KJ5JCO-10 / Direwolf KISS 8001",
|
||||
"status": "Online",
|
||||
"severity": "Critical",
|
||||
"severity": "Degraded",
|
||||
"layer": "Edge / RF",
|
||||
"label": "iGate",
|
||||
"latency": "324 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"latency": "59 ms",
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
},
|
||||
{
|
||||
"name": "APRS-IS",
|
||||
@@ -96,8 +96,8 @@
|
||||
"severity": "Degraded",
|
||||
"layer": "Edge / RF",
|
||||
"label": "External",
|
||||
"latency": "98 ms",
|
||||
"lastCheck": "2026-04-26 17:50:50"
|
||||
"latency": "61 ms",
|
||||
"lastCheck": "2026-04-26 21:13:17"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -11,28 +11,32 @@ with open(NOC_FILE, "r", encoding="utf-8") as file:
|
||||
status = data.get("status", "Unknown")
|
||||
summary = data.get("summary", {})
|
||||
|
||||
online = summary.get("online", "?")
|
||||
offline = summary.get("offline", "?")
|
||||
services = summary.get("services", f"{online}/?")
|
||||
online = int(summary.get("online", 0))
|
||||
offline = int(summary.get("offline", 0))
|
||||
total = online + offline
|
||||
|
||||
if status == "All Systems Online":
|
||||
# 🔥 Determine severity
|
||||
if offline == 0:
|
||||
severity = "Healthy"
|
||||
color = "brightgreen"
|
||||
elif status == "Degraded":
|
||||
elif offline <= 2:
|
||||
severity = "Degraded"
|
||||
color = "yellow"
|
||||
else:
|
||||
severity = "Critical"
|
||||
color = "red"
|
||||
|
||||
# 🔥 Build message
|
||||
message = f"{severity} | {online}/{total} online | {offline} offline"
|
||||
|
||||
badge = {
|
||||
"schemaVersion": 1,
|
||||
"label": "Ced's NOC",
|
||||
"message": f"{status} | {services} online | {offline} offline",
|
||||
"message": message,
|
||||
"color": color
|
||||
}
|
||||
|
||||
BADGE_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(BADGE_FILE, "w", encoding="utf-8") as file:
|
||||
json.dump(badge, file, indent=2)
|
||||
|
||||
print(f"NOC badge written to {BADGE_FILE}")
|
||||
print(badge["message"])
|
||||
print(f"NOC badge updated: {message}")
|
||||
Reference in New Issue
Block a user