giampaolo / psutil

Cross-platform lib for process and system monitoring in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Core usage anomaly

MattiaVerticchio opened this issue · comments

Summary

  • OS: Fedora 39 Sway
  • CPU: Intel N100, 64bit
  • Psutil version: 5.9.5
  • Python version: 3.12.1
  • Type: core

Description

I encountered a bug when using the psutil.cpu_percent(interval=1, percpu=True) function. It returns a list of percentages for each CPU core, but the value for the third core is always very high (around 75-80%) even when the CPU is idling. This does not match the CPU usage shown by Gnome System Monitor.

Screenshot

image

Code
import psutil
import time

for _ in range(10):
    print(psutil.cpu_percent(interval=1, percpu=True))
    time.sleep(1)
Output
[5.0, 1.0, 76.0, 1.0]
[2.0, 3.0, 75.0, 3.0]
[3.0, 0.0, 75.0, 3.0]
[1.0, 4.0, 75.8, 1.0]
[1.0, 4.0, 75.2, 3.0]
[1.0, 1.0, 75.2, 3.0]
[1.0, 2.0, 75.0, 3.0]
[2.0, 5.0, 75.8, 4.0]
[2.0, 6.0, 75.0, 1.0]
[1.0, 4.0, 75.8, 5.0]

I hope this is helpful, thank you for your work on this library! 😁