display and acknowledge alerts

This commit is contained in:
Andreas Wrede
2026-04-03 06:35:45 -04:00
parent c5770006f7
commit 941f3ea4b0
6 changed files with 414 additions and 62 deletions
+30
View File
@@ -307,6 +307,21 @@ class Host:
d["name"] = "<b>%s</b>" % d["name"]
d["dyn"] = str(self.dyn)
d["num"] = self.num
# Add alert counts
warning_count = 0
critical_count = 0
for metric_path, alert_state in self.alert_states.items():
# Import AlertLevel here to avoid circular imports
from .threshold import AlertLevel
if alert_state.level == AlertLevel.WARNING:
warning_count += 1
elif alert_state.level == AlertLevel.CRITICAL:
critical_count += 1
d["alert_warning_count"] = warning_count
d["alert_critical_count"] = critical_count
for c in ["IPv4", "IPv6"]:
if c in self.connections:
cs = self.connections[c].statedict()
@@ -363,6 +378,21 @@ class Host:
ddict[d] = cl
else:
ddict[d] = self.__dict__[d]
# Add alert counts (computed from alert_states)
warning_count = 0
critical_count = 0
if hasattr(self, 'alert_states'):
from .threshold import AlertLevel
for metric_path, alert_state in self.alert_states.items():
if alert_state.level == AlertLevel.WARNING:
warning_count += 1
elif alert_state.level == AlertLevel.CRITICAL:
critical_count += 1
ddict["alert_warning_count"] = warning_count
ddict["alert_critical_count"] = critical_count
return ddict
def jsons(self):