Spaces:
Build error
Build error
File size: 495 Bytes
8c3e275 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from __future__ import annotations
import psutil
def get_cpu_percent() -> float:
return psutil.cpu_percent(interval=0.1)
def get_memory_info() -> dict[str, float]:
mem = psutil.virtual_memory()
return {
"total_gb": round(mem.total / (1024**3), 2),
"used_gb": round(mem.used / (1024**3), 2),
"percent": mem.percent,
}
def get_telemetry() -> dict[str, float]:
return {
"cpu_percent": get_cpu_percent(),
**get_memory_info(),
}
|