Python - get process names,CPU,Mem Usage and Peak Mem Usage in windows

Daniel picture Daniel · May 1, 2013 · Viewed 55.2k times · Source

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.

Answer

Bakuriu picture Bakuriu · May 2, 2013

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.