[python-win32] win32pdhutil Processor Time always returns 99

Tim Golden tim.golden at viacom-outdoor.co.uk
Mon Dec 15 04:39:49 EST 2003


>-----Original Message-----
>From: Martin Beckett [mailto:martin at datactics.co.uk]
>Sent: 12 December 2003 19:24
>To: python-win32 at python.org
>Subject: [python-win32] win32pdhutil Processor Time always returns 99
>
>
>I am trying to get the % CPU load in python on win32
>
>win32pdhutil.GetPerformanceAttributes("Processor(_Total)","% Processor 
>Time")
>only ever returns 99 whatever the machine load ?
>
>Running on Windows XP-pro + ActivePython 2.3.2 Build 231
>
>   Any ideas ?

Nothing that directly answers your question: running the same code
 on my Win2K machine gives the same result, but I have close to
 no knowledge on Win32 performance counters.

However, can I can offer the following ray of hope? The following
 code works for me:

<code>
import wmi
import time

c = wmi.WMI ()
while 1:
  for p in c.Win32_Processor ():
    print "%s running at %d%% load" % (p.Name, p.LoadPercentage)
    time.sleep (5)

</code>

Obviously, I don't know if what else you're doing relies specifically
 on the Performance Counters, in which case this isn't such a useful
 example. Some of them are available via WMI, but I don't know if 
 they all are.

HTH
TJG


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-win32 mailing list