mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-12 05:35:19 +00:00
checkers are now objects, lay foundation for persistent alerts
This commit is contained in:
parent
5d2759c63c
commit
eef6ec59b0
12 changed files with 162 additions and 81 deletions
|
|
@ -1,18 +1,18 @@
|
|||
from psutil import cpu_percent
|
||||
|
||||
from lego_monitoring.alerting import alerts
|
||||
from lego_monitoring.alerting.alert import Alert
|
||||
from lego_monitoring.alerting.enum import AlertType, Severity
|
||||
from lego_monitoring.core import cvars
|
||||
|
||||
IS_TESTING = False
|
||||
|
||||
|
||||
def cpu_check() -> list[alerts.Alert]:
|
||||
def cpu_check() -> list[Alert]:
|
||||
percentage = cpu_percent()
|
||||
config = cvars.config.get().checks.cpu
|
||||
if config.critical_percentage and (IS_TESTING or percentage > config.critical_percentage):
|
||||
return [
|
||||
alerts.Alert(
|
||||
Alert(
|
||||
alert_type=AlertType.CPU,
|
||||
message=f"CPU load: {percentage:.2f}% > {config.critical_percentage:.2f}%",
|
||||
severity=Severity.CRITICAL,
|
||||
|
|
@ -20,7 +20,7 @@ def cpu_check() -> list[alerts.Alert]:
|
|||
]
|
||||
elif config.warning_percentage and (IS_TESTING or percentage > config.warning_percentage):
|
||||
return [
|
||||
alerts.Alert(
|
||||
Alert(
|
||||
alert_type=AlertType.CPU,
|
||||
message=f"CPU load: {percentage:.2f}% > {config.warning_percentage:.2f}%",
|
||||
severity=Severity.WARNING,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue