[python-win32] getting reliable data from win32pdh

daniel.warren@amd.com daniel.warren@amd.com
Wed, 26 Feb 2003 11:47:08 -0800


Hi,

I'm trying to use the win32pdhquery interface to the windows performance counters to watch the activity of certain programs.  I wrote a simple script which chooses the data to log, runs the collectdatawhile() routine, runs the program to watch, and then saves the data to a CSV file, in the same format as the windows perfmon does.  However, the data it logs has a lot of zeroes in it, suggesting that it couldn't actually sample the counter that instant.  Some counters virtually never get sampled, others will get data 1 out of 5 times for the first 30sec or so, and then will just be all zeros.  Yet others will have a relatively complete set.  The built in windows perfmon GUI seems to have a much higher hit rate - some counters it also can't seem to latch on to, but when it does, the data is nearly always there.  I tried increasing the priority of the collectdatawhile_slave() thread, which fixed a different problem I was having (under heavy load, the logging interval would be irre!
gular - anywhere from 1 sec to 3.2 sec, although I wanted every second).  Unfortunately, that didn't change the success rate in gathering meaningful data.  It is like that idle as well as under load.  I've tried on a few systems, running various versions of Win2K and WinXP, running Python 2.2.2.  Any suggestions?

Thanks,
Dan