mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 04:41:10 +00:00
RAM percentage recording. removed unnecessary sensors
This commit is contained in:
parent
7455a7b7d6
commit
4dbd81b352
2 changed files with 6 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ class CpuSensor:
|
||||||
@dataclass
|
@dataclass
|
||||||
class RamSensor:
|
class RamSensor:
|
||||||
current_avail: int
|
current_avail: int
|
||||||
|
current_avail_percentage: float
|
||||||
warning_avail: int = 4 * 1024**3
|
warning_avail: int = 4 * 1024**3
|
||||||
critical_avail: int = 2 * 1024**3
|
critical_avail: int = 2 * 1024**3
|
||||||
|
|
||||||
|
|
@ -69,7 +70,7 @@ class Sensors:
|
||||||
# skipping first 8 elements as they're not informative
|
# skipping first 8 elements as they're not informative
|
||||||
# while the last elements duplicate the first ones,
|
# while the last elements duplicate the first ones,
|
||||||
# but with more understandable names
|
# but with more understandable names
|
||||||
for sensor in sensors[7::]:
|
for sensor in sensors[7:-2:]:
|
||||||
temp_sensors[s_type].append(
|
temp_sensors[s_type].append(
|
||||||
TemperatureSensor(
|
TemperatureSensor(
|
||||||
sensor_type=s_type,
|
sensor_type=s_type,
|
||||||
|
|
@ -88,7 +89,9 @@ class Sensors:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_ram() -> RamSensor:
|
def get_ram() -> RamSensor:
|
||||||
return RamSensor(current_avail=virtual_memory().available)
|
ram = virtual_memory()
|
||||||
|
return RamSensor(current_avail=ram.available,
|
||||||
|
current_avail_percentage=ram.percent)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ def pretty_print():
|
||||||
s = Sensors.get_cpu()
|
s = Sensors.get_cpu()
|
||||||
print(f"Used CPU: {s.current_load}%")
|
print(f"Used CPU: {s.current_load}%")
|
||||||
s = Sensors.get_ram()
|
s = Sensors.get_ram()
|
||||||
print(f"Available RAM: {(s.current_avail / 1024**3):.2f} GiB")
|
print(f"Available RAM: {(s.current_avail / 1024**3):.2f} ({s.current_avail_percentage}%) GiB")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue