Examples of usage for win32pdh.ExpandCounterPath()?

Mark Hammond MHammond at skippinet.com.au
Sat Jun 19 02:28:27 CEST 1999


calouro wrote in message <376ac08a.13773775 at news.worldtalk.com>...

>The win32 extensions work well once I figure out how to call them
>correctly -- which is much easier if I have some examples to study and
>experiment with.

The help files and looking at win32pdhutil contain the hints you need.  The
biggest problem with win32pdh is knowing what counters to use, and their
exact format.

OK - lets browse for the counters.  In the dialog that is presented, we
select a counter, and press "Add":

>>> import win32pdhutil
>>> win32pdhutil.browse()
Browsing for counters...
Value of '\\BOBCAT\Process(_Total)\% Processor Time' is 95.5669019211
Added '% Processor Time' on object 'Process

OK - now we know the format of at least one counter.  The documentation to
ExpandCounterPath implies you can add wildcards.  So, lets try it:

>>> import win32pdh
>>> from pprint import pprint
>>> pprint(win32pdh.ExpandCounterPath(r"\\bobcat\Process(_Total)\*"))
['\\\\bobcat\\Process/_Total)\\% Processor Time',
 '\\\\bobcat\\Process/_Total)\\% User Time',
 '\\\\bobcat\\Process/_Total)\\% Privileged Time',
 '\\\\bobcat\\Process/_Total)\\Virtual Bytes Peak',
 '\\\\bobcat\\Process/_Total)\\Virtual Bytes',
etc!
]

Mark.






More information about the Python-list mailing list