mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-21 23:32:59 +00:00
Jörn-Michael Miehe
8b532829a5
ReportData mutable, Report immutable class Report has builtin `aggregate`
20 lines
368 B
Python
20 lines
368 B
Python
import psutil
|
|
|
|
from ..settings import SETTINGS
|
|
from ._report import Report, ReportData
|
|
|
|
|
|
def _hwdata() -> ReportData:
|
|
return ReportData(
|
|
name=SETTINGS.cpu.name,
|
|
value=psutil.cpu_percent(interval=1),
|
|
)
|
|
|
|
|
|
def cpu() -> Report | None:
|
|
if not SETTINGS.cpu.enabled:
|
|
return None
|
|
|
|
data = _hwdata()
|
|
|
|
return data.report(SETTINGS.cpu)
|