Freigeben über


Demystifying .Net CLR Perfromance Counter

Hi Friends!!!

I am back in business and apologies for out of contact for a while. Lot of exciting thing happened over past few months. Finally I landed where I always wanted to be so thanks for your support so far and yes your guess is right from the blog addressJ.

I was waiting to right my first post with some exciting information. Exciting means hidden to the world and internet search engines could not find! In my usual style here it goes:

Scenario:

I was at customer site and my task was to monitor the IIS System health and that obliviously means monitoring the application health. I decided to setup performance counter for a start and I opened the Process counter as shown in following figure:

So server was hosting multiple web application and sever had multiple worker processes. In the Instance list all worker process was appearing as w3wp, w3wp#1, w3wp#2 and w3wp#n and so on. Problem was which one is associated with correct application pool?

Resolution:

I executed the following command to get a list of worker processes running on the server and associated process ID.

C:\windows\system32\cscript c:\windows\system32\iisapp.vbs

Output was something like below:

IISApp.vbs 

Then I remembered the one blog post from very dear friend of mine:

https://blogs.technet.com/marcelofartura/archive/2006/09/14/perfmon-s-counters-output-format-tip.aspx

I applied the registry changes as said and voila!!! I got the output as below:

 

Job done! Hum... I am sure you are wondering what is the point of having this blog entry? Such a waste of time isn’t it? If you are thinking this than wait...

I opened .Net CLR Counters and specifically .Net CLR Exceptions and .Net CLR Memory and I saw the following:

 

Hum!! Something didn’t work as expected. I verified the registry entries and appeared correct to me. I came to conclusion that this registry modifications are not working for .NET CLR counters. Question was how to monitor .Net CLR counters for specific application pool only?

I decided that it is time to call the internal help line and guess what within hours I got reply and reply was amazing that I decided to write this blog.

Guy told me to look for under “.Net CLR Memory” Performance object and asked me “what is the 4th last counter you see?” I was amazed what it has to do with 4th last counter? I looked the counter and it was full of surprise!!! It seemed that “Promoted Finalization Memory from Gen1" is the holly grail!!!! The last value of that counter was actually the worker process ID!! Now you got the relationship between .Net CLR performance counters and Worker process ID as well.

 

Takeaway:

When you have .Net 1.1 installed it loads the .Net 1.1 performance counters and there is no easy way to get this relationship established. However, in .Net 2.0 onwards you can unload the .Net 1.1 counters and reload the .Net 2.0 specific counters with following instructions:

1) Go to \Windows\Microsoft.NET\Framework\v2.0.50727

2) Run “unlodctr .NetFramework”

3) Run “lodctr corperfmonsymbols.ini”

This should load the .Net 2.0 counters from corperfmonsymbols.ini. So what is the difference? Well, see the screenshot below:

 

Now you have the real name of performance counter as well along with real value. Demystifying the secret! Though you have counter listed, it will not work with .Net 1.1.

Well this solution provided as it is and you are at your own risk! Please don’t take it as an official supported way to implement and it is kind of working solution. We should expect a lot of improvement on this side with .Net 4.0 so wait and watch!

PS: Special Thanks to Mr. A. Kamath who assisted me with this problem.