[python-win32] win32pdhutil Processor Time always returns 99
Segura Blanc, Claudio E.
claudio.segurablanc at bancofrances.com.ar
Wed Oct 5 19:59:27 CEST 2005
This is an aparent solution
only sintaxis "Processor"
By
import win32pdh, time, win32pdhutil
path = win32pdh.MakeCounterPath( (None,"Processor","_Total", None, -1, "%
Processor Time") ) #Idle, _Total
print path
# open the query, and add the counter to the query
#print win32pdhutil.GetPerformanceAttributes("Process(_Total)","% Processor
Time")
base = win32pdh.OpenQuery()
print base
counter = win32pdh.AddCounter(base, path)
print counter
# collect the data for the query object. We need to collect the query data
# twice to be able to calculate the % Processor Time
win32pdh.CollectQueryData(base)
time.sleep(1)
win32pdh.CollectQueryData(base)
# Get the formatted value of the counter
print "Uso de procesador al", (win32pdh.GetFormattedCounterValue(counter,
win32pdh.PDH_FMT_LONG)[1]), "%"
More information about the Python-win32
mailing list