Rahul Rahul - 17 days ago 7
Python Question

How to capture the CPU core usage from system monitor program?

I have a python program running using a parallel python. This module scales my job submitted to individual cores of my computer , I don't know how does it do it but when i check my system monitor it clearly shows 100% usage in both the cores (I am running some really heavy jobs).

Is there any python module or tool which allows me to capture the individual core usage from the system monitor program when I run my job?

Answer

psutil:

>>> for x in range(3):
...     psutil.cpu_percent(interval=1, percpu=True)
... 
[4.0, 6.9]
[7.0, 8.5]
[1.2, 9.0]