18 lines
389 B
Python
18 lines
389 B
Python
import time
|
|
import psutil
|
|
|
|
|
|
class MetricsCollector:
|
|
"""
|
|
Lightweight node telemetry sampler.
|
|
"""
|
|
|
|
def sample(self):
|
|
|
|
return {
|
|
"cpu": psutil.cpu_percent(interval=0.1),
|
|
"memory": psutil.virtual_memory().percent,
|
|
"load": psutil.getloadavg()[0] if hasattr(psutil, "getloadavg") else 0,
|
|
"timestamp": time.time(),
|
|
}
|