mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 12:45:19 +00:00
move checks to upsmon, where possible
This commit is contained in:
parent
9518527beb
commit
09a9cfe310
3 changed files with 53 additions and 51 deletions
|
|
@ -3,9 +3,10 @@ from dataclasses import dataclass
|
|||
|
||||
from psutil import cpu_percent, sensors_temperatures, virtual_memory
|
||||
|
||||
from .enums import UPSStatus
|
||||
from alerting import alerts
|
||||
|
||||
from .enums import UPSStatus
|
||||
|
||||
|
||||
@dataclass
|
||||
class TemperatureSensor:
|
||||
|
|
@ -116,11 +117,13 @@ class Sensors:
|
|||
try:
|
||||
raw_data = subprocess.run(["upsc", "cp1300"], stdout=subprocess.PIPE, encoding="utf-8")
|
||||
except FileNotFoundError:
|
||||
await alerts.send_alert(alerts.Alert(
|
||||
alert_type=alerts.AlertType.ERROR,
|
||||
message="upsc is not installed!",
|
||||
severity=alerts.Severity.CRITICAL
|
||||
))
|
||||
await alerts.send_alert(
|
||||
alerts.Alert(
|
||||
alert_type=alerts.AlertType.ERROR,
|
||||
message="upsc is not installed!",
|
||||
severity=alerts.Severity.CRITICAL,
|
||||
)
|
||||
)
|
||||
return None
|
||||
|
||||
sensor_data = UPSSensor()
|
||||
|
|
@ -131,13 +134,9 @@ class Sensors:
|
|||
case "battery.charge":
|
||||
sensor_data.battery_charge_percentage = int(value)
|
||||
case "battery.charge.low":
|
||||
# ? in case we need to evaluate critical% from sensor
|
||||
# sensor_data.battery_critical_percentage = int(value)
|
||||
sensor_data.battery_critical_percentage = 25
|
||||
sensor_data.battery_critical_percentage = int(value)
|
||||
case "battery.charge.warning":
|
||||
# ? in case we need to evaluate warning% from sensor
|
||||
# sensor_data.battery_warning_percentage = int(value)
|
||||
sensor_data.battery_warning_percentage = 50
|
||||
sensor_data.battery_warning_percentage = int(value)
|
||||
case "battery.runtime":
|
||||
sensor_data.battery_runtime = int(value)
|
||||
case "ups.status":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue