mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 04:41:10 +00:00
alerting service
This commit is contained in:
parent
84ab61eb00
commit
fcc02da845
5 changed files with 143 additions and 55 deletions
25
misc/checks.py
Normal file
25
misc/checks.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from alerting import alerts
|
||||
from misc import sensors
|
||||
|
||||
|
||||
def temp_check() -> set[alerts.Alert]:
|
||||
alert_list = []
|
||||
temps = sensors.Sensors.get_temperatures()
|
||||
for _, sensor_list in temps.items():
|
||||
for sensor in sensor_list:
|
||||
if sensor.critical_temp is not None and sensor.current_temp > sensor.critical_temp:
|
||||
alert = alerts.Alert(
|
||||
alert_type=alerts.AlertType("TEMP"),
|
||||
message=f"{sensor.sensor_type} {sensor.sensor_label}: {sensor.current_temp}°C > {sensor.critical_temp}°C",
|
||||
severity=alerts.Severity.CRITICAL,
|
||||
)
|
||||
elif sensor.highest_temp is not None and sensor.current_temp > sensor.highest_temp:
|
||||
alert = alerts.Alert(
|
||||
alert_type=alerts.AlertType("TEMP"),
|
||||
message=f"{sensor.sensor_type} {sensor.sensor_label}: {sensor.current_temp}°C > {sensor.critical_temp}°C",
|
||||
severity=alerts.Severity.WARNING,
|
||||
)
|
||||
else:
|
||||
continue
|
||||
alert_list.append(alert)
|
||||
return alert_list
|
||||
Loading…
Add table
Add a link
Reference in a new issue