adapt rest of checks to use OK alerts

This commit is contained in:
Alex Tau 2025-08-15 18:15:13 +03:00
parent 5f9952314d
commit be7b3dbeed
5 changed files with 19 additions and 7 deletions

View file

@ -27,4 +27,4 @@ def cpu_check() -> list[Alert]:
)
]
else:
return []
return [Alert(alert_type=AlertType.CPU, message=f"CPU load: {percentage:.2f}% (nominal)", severity=Severity.OK)]

View file

@ -25,8 +25,8 @@ class NetIOTracker:
stat_name: str,
interface: str,
) -> Optional[Alert]:
if critical_threshold and (IS_TESTING or current_stat_bytes_per_sec >= critical_threshold):
current_stat_natural = naturalsize(current_stat_bytes_per_sec, binary=True)
if critical_threshold and (IS_TESTING or current_stat_bytes_per_sec >= critical_threshold):
critical_threshold_natural = naturalsize(critical_threshold, binary=True)
return Alert(
alert_type=AlertType.NET,
@ -34,13 +34,18 @@ class NetIOTracker:
severity=Severity.CRITICAL,
)
elif warning_threshold and (IS_TESTING or current_stat_bytes_per_sec >= warning_threshold):
current_stat_natural = naturalsize(current_stat_bytes_per_sec, binary=True)
warning_threshold_natural = naturalsize(warning_threshold, binary=True)
return Alert(
alert_type=AlertType.NET,
message=f"Interface {interface} {stat_name} {current_stat_natural}/s >= {warning_threshold_natural}/s",
severity=Severity.WARNING,
)
else:
return Alert(
alert_type=AlertType.NET,
message=f"Interface {interface} {stat_name} {current_stat_natural}/s (nominal)",
severity=Severity.OK,
)
def net_check(self) -> list[Alert]:
alerts = []

View file

@ -27,4 +27,6 @@ def ram_check() -> list[Alert]:
)
]
else:
return []
return [
Alert(alert_type=AlertType.RAM, message=f"RAM usage: {percentage:.2f}% (nominal)", severity=Severity.OK)
]

View file

@ -24,8 +24,11 @@ def temp_check() -> list[Alert]:
severity=Severity.WARNING,
)
else:
continue
alert = Alert(
alert_type=AlertType.TEMP,
message=f"{sensor} {r.label}: {r.current_temp}°C (nominal)",
severity=Severity.OK,
)
alert_list.append(alert)
if len(alert_list) == 0:
alert_list.append(Alert(alert_type=AlertType.TEMP, message="All sensors nominal", severity=Severity.OK))
return alert_list

View file

@ -50,5 +50,7 @@ async def vulnix_check() -> list[Alert]:
if IS_TESTING:
alert_list[0].message += "\n(just testing)"
return [alert_list[0]]
elif len(alert_list) == 0:
return [Alert(AlertType.VULN, message="No vulnerabilities found", severity=Severity.OK)]
else:
return alert_list