2023-08-31 15:31:25 +00:00
|
|
|
from typing import Iterator
|
|
|
|
|
2023-08-31 11:17:19 +00:00
|
|
|
import psutil
|
|
|
|
|
|
|
|
from ..settings import SETTINGS
|
2023-08-31 15:23:00 +00:00
|
|
|
from ._report import Report, ReportData
|
|
|
|
|
|
|
|
|
2023-08-31 15:31:25 +00:00
|
|
|
def _hwdata() -> Iterator[ReportData]:
|
2023-09-01 15:18:57 +00:00
|
|
|
yield ReportData.from_settings(
|
2023-08-31 15:23:00 +00:00
|
|
|
name=SETTINGS.cpu.name,
|
2023-09-02 01:56:41 +00:00
|
|
|
value=psutil.cpu_percent(interval=SETTINGS.cpu.interval),
|
2023-09-01 15:18:57 +00:00
|
|
|
settings=SETTINGS.cpu,
|
2023-08-31 15:23:00 +00:00
|
|
|
)
|
2023-08-31 11:17:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
def cpu() -> Report | None:
|
2023-08-31 15:31:25 +00:00
|
|
|
return Report.aggregate(
|
|
|
|
settings=SETTINGS.cpu,
|
|
|
|
get_data=_hwdata,
|
|
|
|
)
|