Retrieve the current CPU usage. It utilizes the `psutil` library. Function `psutil.cpu_percent()` returns a float representing the current system-wide CPU utilization as a percentage.
()
| 104 | |
| 105 | |
| 106 | def get_cpu_info() -> CpuInfo: |
| 107 | """Retrieve the current CPU usage. |
| 108 | |
| 109 | It utilizes the `psutil` library. Function `psutil.cpu_percent()` returns a float representing the current |
| 110 | system-wide CPU utilization as a percentage. |
| 111 | """ |
| 112 | logger.debug('Calling get_cpu_info()...') |
| 113 | cpu_percent = psutil.cpu_percent(interval=0.1) |
| 114 | return CpuInfo(used_ratio=cpu_percent / 100) |
| 115 | |
| 116 | |
| 117 | def get_memory_info() -> MemoryInfo: |