Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Performance / November 2003

Tip: Looking for answers? Try searching our database.

System.Diagnostics.PerformanceCounter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jerry Negrelli - 13 Nov 2003 22:24 GMT
Does anyone have a good reference to the inner workings
of the PerformanceCounter class and its related classes?  

Specifically, I'd like to know how a PerformanceCounter
object connects to a remote machine to retrieve data.  Is
it through WMI, SNMP, etc.??

Even if it's just "Run ildasm on the System.dll assembly
and look at ClassX, method Q", that answer would be very
helpful.

JER
David Gutierrez[MSFT] - 14 Nov 2003 17:24 GMT
I don't know of any references, but I do know that PerformanceCounter uses
the remote registry apis to retrieve data.   Something like
RegistryKey r = RegistryKey.OpenRemoteBaseKey(RegistryHive.PerformanceData,
machineName);
r.GetValue("global");

David

--------------------
| Content-Class: urn:content-classes:message
| From: "Jerry Negrelli" <jerry.negrelli@nospamdatascientific.com>
[quoted text clipped - 13 lines]
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.performance:5960
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.performance
[quoted text clipped - 11 lines]
|
| JER
Jerry Negrelli - 17 Nov 2003 14:50 GMT
Now is remote registry used to retrieve the list of
available counters or is that actually grabbing the
values?  I'd be quite surprised if my system is
constantly hitting the registry with Performance Counter
value updates.

>-----Original Message-----
>I don't know of any references, but I do know that PerformanceCounter uses
[quoted text clipped - 41 lines]
>
>.
David Gutierrez[MSFT] - 17 Nov 2003 17:58 GMT
It's used for both.  But you're not really hitting the registry, because
the PerformanceData hive (or HKEY_PERFORMANCE_DATA if you're thinking about
Win32) isn't strictly part of the registry.   It's just the way things are
designed that to read perf counter data, you use the registry apis on
HKEY_PERFORMANCE_DATA.  
David

--------------------
| From: "Jerry Negrelli" <jerry.negrelli@nospamdatascientific.com>
| Subject: RE: System.Diagnostics.PerformanceCounter
| Date: Mon, 17 Nov 2003 06:50:21 -0800

| Now is remote registry used to retrieve the list of
| available counters or is that actually grabbing the
[quoted text clipped - 61 lines]
| >
| >.
Jerry Negrelli - 17 Nov 2003 20:30 GMT
David,

So if remote registry access is disabled does that imply
that System.Diagnostics.PerformanceCounter class is
disabled remotely?  Or is "remote registry access" not
bound to the registry API?  I'm not clear on how
Performance data is designed as if it is in the registry
but is not actually in it.

JER

>-----Original Message-----
>It's used for both.  But you're not really hitting the registry, because
[quoted text clipped - 76 lines]
>
>.
David Gutierrez[MSFT] - 18 Nov 2003 19:01 GMT
Ok, to read performance data, System.Diagnostics.PerformanceCounter calls
RegQueryValueEx(HKEY_PERFORMANCE_DATA, "global",..)
This IS using the registry because
1) it calls RegQueryValueEx
2) there is a base hive called HKEY_PERFORMANCE_DATA

It IS NOT using the registry because HKEY_PERFORMANCE_DATA is a special
case for RegQueryValueEx that says "go collect performance data".   For the
OS, the "go collect performance data" step is very different than reading a
normal value from the registry.  It's not really important to understand
exactly this works, though.

On the client (the machine doing the reading), it doesn't matter whether
remote registry access is enabled or disabled.  On the server, remote
registry access must be enabled.  
Hope this helps,
David

--------------------
| From: "Jerry Negrelli" <jerry.negrelli@nospamdatascientific.com>
| Sender: "Jerry Negrelli" <jerry.negrelli@nospamdatascientific.com>
[quoted text clipped - 97 lines]
| >
| >.
Jerry Negrelli - 19 Nov 2003 17:10 GMT
Thanks, David.  I stopped the "Remote Registry" service
on one of my remote machines and sure enough, the remote
performance counters stopped working.  So my question is
answered.  ;)

So if remote registry is disabled on a remote machine,
perhaps one could use the Perf objects in WMI to mimic
the Diagnostics.PerformanceCounter querying?  Since WMI
connects over RPC/DCOM, this seems like a viable approach
to collecting perf data without needing remote registry
access...  Thoughts?

JER
David Gutierrez[MSFT] - 19 Nov 2003 17:35 GMT
I'm don't know enough about WMI, to know if that would work.  I'm pretty
sure you're right about WMI not using the registry interface to get perf
data.  On the other hand, I know that WMI reads some other information from
the registry when looking at counters on the local machine.   Maybe it's
different for the remote case?  You'll have to give it a try.
David

--------------------
| From: "Jerry Negrelli" <jerry.negrelli@removethispart-datascientific.com>
| Subject: RE: System.Diagnostics.PerformanceCounter
[quoted text clipped - 12 lines]
|
| JER
Jerry Negrelli - 19 Nov 2003 19:47 GMT
I ran some testing on a remote machine that had remote
registry disabled.  I created a
System.Diagnostics.PerformanceCounter to capture "% User
Time" and it failed, as expected. However, a WMI call to
Win32_PerfFormattedData_PerfProc_Process allowed me to
read the "% User Time" Property successfully.

JER

>-----Original Message-----
>I'm don't know enough about WMI, to know if that would work.  I'm pretty
[quoted text clipped - 23 lines]
>
>.
walter leinert - 15 Nov 2003 17:29 GMT
Hi Jerry,

you could use the famous .NET reflector from Luzt Roeder:
http://www.aisto.com/roeder/dotnet/

This nice tool allows you to look into the internals of the .NET framework
libraries and also to to decompile (most) of the library code.

Regards, Walter

> Does anyone have a good reference to the inner workings
> of the PerformanceCounter class and its related classes?
[quoted text clipped - 8 lines]
>
> JER
Jerry Negrelli - 17 Nov 2003 14:51 GMT
I was using ildasm with a similar intent & keep getting
clost somewhere around
System.Diagnostics.CounterSample ...

JER

>-----Original Message-----
>Hi Jerry,
[quoted text clipped - 21 lines]
>
>.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.