mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-22 07:33:00 +00:00
17 lines
315 B
Python
17 lines
315 B
Python
|
import psutil
|
||
|
|
||
|
from ..settings import SETTINGS
|
||
|
from ._report import Report
|
||
|
|
||
|
|
||
|
def cpu() -> Report | None:
|
||
|
if not SETTINGS.cpu.enabled:
|
||
|
return None
|
||
|
|
||
|
value = psutil.cpu_percent(interval=1)
|
||
|
return Report.new(
|
||
|
settings=SETTINGS.cpu,
|
||
|
name=SETTINGS.cpu.name,
|
||
|
value=value,
|
||
|
)
|