Page 1 of 1

performance counters

PostPosted: Thu Nov 29, 2007 10:57 pm
by ciuly
Hi madshi,

found your piece of code for cpu utilization here http://www.experts-exchange.com/Program ... 27047.html
where did you get the object number (238) and counter number (6)? I can't seem to be able to find anything on the net (obviously it's pretty hard not knowing what to search for)
I'm trying to get some more info, for memory and network card so I need a list of object and counter numbers and their coresponent names. I did find this on msdn, but no connection to the actual numbers.
Aloo, as I saw somwhere, these numbers are not the same for different win versions. What would be a more correct way fo getting this info? the object and counter name would be a good choice but then again, that's just how I see it.
All I want is a little push in the right direction. it seems I'm just not searching right since i can't find anything realy usefull.

thanks.

PostPosted: Sat Dec 01, 2007 10:34 am
by madshi
Unfortunately this is SO long ago, I don't remember any dirty details... :?

Maybe some of the other comments in that Experts Exchange question help? It seems there are some functions that can translate names to indexes somehow?

PostPosted: Sat Dec 01, 2007 9:45 pm
by ciuly
well, no problem. that's a starting point. I'll look into that. thanks ;)

PostPosted: Sun Dec 02, 2007 3:50 pm
by ciuly
found it here
I've implemented a helper unit/function to access performance counters by object and counter name.

thanks for the tip :)

PostPosted: Sun Dec 02, 2007 4:52 pm
by madshi
So are the numbers/names really different in different OSs?

PostPosted: Sun Dec 02, 2007 5:32 pm
by ciuly
dunno :)
this is the article that I read mentioning the differences.

all I did was: get all index-name pairs once at project startup and cache them in a stringlist as "name=index" so I can use cache.values[name] to get the index.
that will work on all systems but not with my current code to get the value since I am using your code where I get the object first and then iterate through the counters. I'll have to document a little on a way to get the counter dirrectly, if that is at all possible.
so if the guy is right, this won't work on all systems. I don't have a way to test it so this will probably be tested by my client :)