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

后端 未结 3 1257
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 03:20

    I like using wmic on Windows. You can run it from the command-line, so you can run it from Python.

    from subprocess import Popen,PIPE
    proc = Popen('wmic cpu',stdout=PIPE, stderr=PIPE)
    print str(proc.communicate())
    

    With wmic you can get processes, cpu, and memory info easily. Just use wmic cpu, wmic process, and wmic memphysical. You can also filter out certain attributes by using wmic get . And you can get a list of all commands with wmic /?. Hope that helps!

    You can check out the official documentation for WMIC here: http://technet.microsoft.com/en-us/library/bb742610.aspx

提交回复
热议问题