diff --git a/src/lego_monitoring/checks/cpu.py b/src/lego_monitoring/checks/cpu.py index dc19ecf..594c1d6 100644 --- a/src/lego_monitoring/checks/cpu.py +++ b/src/lego_monitoring/checks/cpu.py @@ -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)] diff --git a/src/lego_monitoring/checks/net.py b/src/lego_monitoring/checks/net.py index 62c59c8..073bd8f 100644 --- a/src/lego_monitoring/checks/net.py +++ b/src/lego_monitoring/checks/net.py @@ -25,8 +25,8 @@ class NetIOTracker: stat_name: str, interface: str, ) -> 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): - current_stat_natural = naturalsize(current_stat_bytes_per_sec, binary=True) 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 = [] diff --git a/src/lego_monitoring/checks/ram.py b/src/lego_monitoring/checks/ram.py index f1eb40d..e91c891 100644 --- a/src/lego_monitoring/checks/ram.py +++ b/src/lego_monitoring/checks/ram.py @@ -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) + ] diff --git a/src/lego_monitoring/checks/temp/__init__.py b/src/lego_monitoring/checks/temp/__init__.py index 4da183a..e461148 100644 --- a/src/lego_monitoring/checks/temp/__init__.py +++ b/src/lego_monitoring/checks/temp/__init__.py @@ -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 diff --git a/src/lego_monitoring/checks/vulnix/__init__.py b/src/lego_monitoring/checks/vulnix/__init__.py index 9fefcff..cd43c57 100644 --- a/src/lego_monitoring/checks/vulnix/__init__.py +++ b/src/lego_monitoring/checks/vulnix/__init__.py @@ -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