Writing Windows performance counters

Saravanan D junk at microsoft.com
Wed Feb 18 07:36:11 EST 2004


Examples which are given the OReilly site (Python Win32 Programming) does
not work properly.  Could you please help me on that.

Saravanan D
"Mark Hammond" <mhammond at skippinet.com.au> wrote in message
news:c074fa$2shp$1 at arachne.labyrinth.net.au...
> David Mitchell wrote:
>
> > Could someone point me towards some sample code that creates performance
> > counters and updates them?  I suspect it's possible using
perfmondata.dll
> > that comes with win32all, but can't begin to guess how to get started.
>
> I thought there was sample code in win32all, but it looks like it never
> got created - but 1/2 of it is there.
>
> The win32\demos\service\install directory has a .h and a .ini file that
> are used by Windows itself when installing the perfmon data.
>
> Somewhere, your runtime code should implement code similar to:
>
> counters = [] # Empty list to fill with counters.
>
> # Counter of document opens.
> # Magic numbers (2, 4, 6) must match header and ini file used
> # at install - could lookup ini, but then I'd need it at runtime
> counterSomething=perfmon.CounterDefinition(2)
> counterSomething.DefaultScale = 1
> counters.append(counterSomething)
>
> counterSomethingElse=perfmon.CounterDefinition(4)
> counterSomethingElse.DefaultScale = 1
> counters.append(counterDocSave)
>
> perfObjectType = perfmon.ObjectType(counters)
>
> # end of sample
>
> The magic numbers must match the .h and .ini (which is a requirement of
> Windows, not us!)  Once the above code has been run, 'counterSomething'
> and 'counterSomethingElse' can have their 'Increment' method called, to
> increment the counter.
>
> Note that I don't try and hide the win32 gory details here, so you
> really must read the MS documentation on this complicated mechanism.
>
> Let me know if you would like any help.  A very useful thing to do would
> be to create a sub-class of the existing demo service, with the subclass
> doing nothing other than providing the perfmon data.  This was always my

> intent.  If you have trouble getting it going, providing the above as
> sample code to demonstrate your problem would get a good response ;)
>
> Mark.
>





More information about the Python-list mailing list