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

后端 未结 3 1270
Happy的楠姐
Happy的楠姐 2020-12-14 02:55

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

3条回答
  •  渐次进展
    2020-12-14 02:59

    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.

提交回复
热议问题