Get python cpu usage

6,979

Solution 1

Us psutil module, it provides for memory, cpu, netowrk, etc usages. Visit their project webpage http://code.google.com/p/psutil/ .

Solution 2

Lucky ol' you gets to dig around in WMI. Check out the Python module 'wmi' which is about as good as I've seen.

Solution 3

You are missing the python win32 extensions which you can find here.

Share:
6,979
Wegged
Author by

Wegged

Sysadmin of a small network ~30pc's 2 servers. I like IT, and i'm doing this as an extra responsability at my job. Keeping IT in the company works great for us :)

Updated on September 17, 2022

Comments

  • Wegged
    Wegged over 1 year

    Anyone using a Python script to monitor CPU usage on a Windows machine ? i've google for some time but have not been able to find any usable script. could you guys show me some example of what you're using ?

    Here is the errors i got.

        Traceback (most recent call last):
      File "test.py", line 1, in 
        import wmi
      File "c:\Python26\lib\site-packages\wmi.py", line 141, in 
        from win32com.client import GetObject, Dispatch
    ImportError: No module named win32com.client
    
    • Alex J
      Alex J almost 15 years
      Did you install pywin32?
    • Wegged
      Wegged almost 15 years
      howdy, i installed win32 on another machine and it works like a charm. for my developing app i decided to use perl instead, since the ActivePerl package installer is very easy to use, and permits me to search and add what pachets i do need
  • Alex J
    Alex J almost 15 years
    What errors did you get?
  • Wegged
    Wegged almost 15 years
    i updated the question.