I am wanting to get a list of all the process names, CPU, Mem Usage and Peak Mem Usage. I was hoping I could use ctypes. but I am happy to hear any other options. Thanks for your time.
Get current CPU usage using psutil The function psutil. cpu_percent() provides the current system-wide CPU utilization in the form of a percentage.
You can use it by putting the @profile decorator around any function or method and running python -m memory_profiler myscript. You'll see line-by-line memory usage once your script exits.
You can use psutil
.
For example, to obtain the list of process names:
process_names = [proc.name() for proc in psutil.process_iter()]
For info about the CPU use psutil.cpu_percent
or psutil.cpu_times
. For info about memory usage use psutil.virtual_memory
.
Note that psutil works with Linux, OS X, Windows, Solaris and FreeBSD and with python 2.4 through 3.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With