mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-09 20:31:10 +00:00
adapt rest of checks to use OK alerts
This commit is contained in:
parent
5f9952314d
commit
be7b3dbeed
5 changed files with 19 additions and 7 deletions
|
|
@ -27,4 +27,4 @@ def cpu_check() -> list[Alert]:
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
return []
|
return [Alert(alert_type=AlertType.CPU, message=f"CPU load: {percentage:.2f}% (nominal)", severity=Severity.OK)]
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ class NetIOTracker:
|
||||||
stat_name: str,
|
stat_name: str,
|
||||||
interface: str,
|
interface: str,
|
||||||
) -> Optional[Alert]:
|
) -> Optional[Alert]:
|
||||||
|
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):
|
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)
|
|
||||||
critical_threshold_natural = naturalsize(critical_threshold, binary=True)
|
critical_threshold_natural = naturalsize(critical_threshold, binary=True)
|
||||||
return Alert(
|
return Alert(
|
||||||
alert_type=AlertType.NET,
|
alert_type=AlertType.NET,
|
||||||
|
|
@ -34,13 +34,18 @@ class NetIOTracker:
|
||||||
severity=Severity.CRITICAL,
|
severity=Severity.CRITICAL,
|
||||||
)
|
)
|
||||||
elif warning_threshold and (IS_TESTING or current_stat_bytes_per_sec >= warning_threshold):
|
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)
|
warning_threshold_natural = naturalsize(warning_threshold, binary=True)
|
||||||
return Alert(
|
return Alert(
|
||||||
alert_type=AlertType.NET,
|
alert_type=AlertType.NET,
|
||||||
message=f"Interface {interface} {stat_name} {current_stat_natural}/s >= {warning_threshold_natural}/s",
|
message=f"Interface {interface} {stat_name} {current_stat_natural}/s >= {warning_threshold_natural}/s",
|
||||||
severity=Severity.WARNING,
|
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]:
|
def net_check(self) -> list[Alert]:
|
||||||
alerts = []
|
alerts = []
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,6 @@ def ram_check() -> list[Alert]:
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
return []
|
return [
|
||||||
|
Alert(alert_type=AlertType.RAM, message=f"RAM usage: {percentage:.2f}% (nominal)", severity=Severity.OK)
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,11 @@ def temp_check() -> list[Alert]:
|
||||||
severity=Severity.WARNING,
|
severity=Severity.WARNING,
|
||||||
)
|
)
|
||||||
else:
|
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)
|
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
|
return alert_list
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,7 @@ async def vulnix_check() -> list[Alert]:
|
||||||
if IS_TESTING:
|
if IS_TESTING:
|
||||||
alert_list[0].message += "\n(just testing)"
|
alert_list[0].message += "\n(just testing)"
|
||||||
return [alert_list[0]]
|
return [alert_list[0]]
|
||||||
|
elif len(alert_list) == 0:
|
||||||
|
return [Alert(AlertType.VULN, message="No vulnerabilities found", severity=Severity.OK)]
|
||||||
else:
|
else:
|
||||||
return alert_list
|
return alert_list
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue