mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-23 07:53:02 +00:00
21 lines
450 B
Python
21 lines
450 B
Python
from typing import Iterator
|
|
|
|
import psutil
|
|
|
|
from ..settings import SETTINGS
|
|
from ._report import Report, ReportData
|
|
|
|
|
|
def _hwdata() -> Iterator[ReportData]:
|
|
yield ReportData.from_settings(
|
|
name=SETTINGS.cpu.name,
|
|
value=psutil.cpu_percent(interval=SETTINGS.cpu.interval),
|
|
settings=SETTINGS.cpu,
|
|
)
|
|
|
|
|
|
def cpu() -> Report | None:
|
|
return Report.aggregate(
|
|
settings=SETTINGS.cpu,
|
|
get_data=_hwdata,
|
|
)
|