mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-09 20:31: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
|
||||
class RamSensor:
|
||||
current_avail: int
|
||||
current_avail_percentage: float
|
||||
warning_avail: int = 4 * 1024**3
|
||||
critical_avail: int = 2 * 1024**3
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ class Sensors:
|
|||
# skipping first 8 elements as they're not informative
|
||||
# while the last elements duplicate the first ones,
|
||||
# but with more understandable names
|
||||
for sensor in sensors[7::]:
|
||||
for sensor in sensors[7:-2:]:
|
||||
temp_sensors[s_type].append(
|
||||
TemperatureSensor(
|
||||
sensor_type=s_type,
|
||||
|
|
@ -88,7 +89,9 @@ class Sensors:
|
|||
|
||||
@staticmethod
|
||||
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__":
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ def pretty_print():
|
|||
s = Sensors.get_cpu()
|
||||
print(f"Used CPU: {s.current_load}%")
|
||||
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__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue