mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 04:41:10 +00:00
refactor Sensors a bit
This commit is contained in:
parent
00b10f804a
commit
fe03aa69dd
1 changed files with 18 additions and 19 deletions
37
sensors.py
37
sensors.py
|
|
@ -12,37 +12,36 @@ class TemperatureSensor:
|
|||
|
||||
|
||||
class Sensors:
|
||||
# !!!WARNING!!! TONS of shit code gonna be below
|
||||
@staticmethod
|
||||
def get_temperatures() -> dict[str, list[TemperatureSensor]]:
|
||||
temp_sens = sensors_temperatures()
|
||||
psutil_temp_sensors = sensors_temperatures()
|
||||
|
||||
temp_sensors = {}
|
||||
|
||||
for k, v in temp_sens.items():
|
||||
if k not in temp_sensors.keys():
|
||||
temp_sensors[k] = []
|
||||
match(k):
|
||||
for s_type, sensors in psutil_temp_sensors.items():
|
||||
if s_type not in temp_sensors.keys():
|
||||
temp_sensors[s_type] = []
|
||||
match(s_type):
|
||||
case "nvme":
|
||||
for i in v:
|
||||
temp_sensors[k].append(TemperatureSensor(
|
||||
sensor_type=k,
|
||||
sensor_label=i.label,
|
||||
current_temp=i.current,
|
||||
highest_temp=i.high,
|
||||
critical_temp=i.critical
|
||||
for sensor in sensors:
|
||||
temp_sensors[s_type].append(TemperatureSensor(
|
||||
sensor_type=s_type,
|
||||
sensor_label=sensor.label,
|
||||
current_temp=sensor.current,
|
||||
highest_temp=sensor.high,
|
||||
critical_temp=sensor.critical
|
||||
))
|
||||
case "amdgpu":
|
||||
temp_sensors[k].append(TemperatureSensor(
|
||||
sensor_type=k,
|
||||
temp_sensors[s_type].append(TemperatureSensor(
|
||||
sensor_type=s_type,
|
||||
sensor_label="Integrated GPU",
|
||||
current_temp=v[0].current,
|
||||
current_temp=sensors[0].current,
|
||||
))
|
||||
case "k10temp":
|
||||
temp_sensors[k].append(TemperatureSensor(
|
||||
sensor_type=k,
|
||||
temp_sensors[s_type].append(TemperatureSensor(
|
||||
sensor_type=s_type,
|
||||
sensor_label="AMD CPU",
|
||||
current_temp=v[0].current,
|
||||
current_temp=sensors[0].current,
|
||||
critical_temp=95.0 # hardcoded because we have R9 7900X
|
||||
))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue