Solved

ASP.NET Performance Counters

Posted on 2010-09-06
6
501 Views
Last Modified: 2012-05-10
Hello,

We are trying to build a page which displays the Asp.Net Application counters for caching and errors of a specific site.  

The issue is that the method requires an instance to be passed into it.  When I list out all the possible instances under my account, they look like the following:

instance=_LM_W3SVC_28_ROOT

instance=_LM_W3SVC_147_ROOT

instance=_LM_W3SVC_148_ROOT

instance=_LM_W3SVC_154_ROOT

instance=_LM_W3SVC_167_ROOT

instance=_LM_W3SVC_168_ROOT

instance=_LM_W3SVC_244_ROOT

instance=_LM_W3SVC_255_ROOT

instance=__Total__

I have six websites, all with dedicated application pools under IIS. Is there anyway to determine which instance is for a specific site?  ARe these instances static, meaning, will they stay the same all the time?  

I basically want to figure out which instance, if they are static, is for the site I want and pass it into a method to get the counters.  The code below is what i used to display all available instances on my account out to screen.

If they aren't static or singular for each site, then I need ideas on how to do this.  

Thanks.
PerformanceCounterCategory cat = new PerformanceCounterCategory("ASP.NET Applications");



            string[] instances = cat.GetInstanceNames();

            foreach (string instance in instances)

            {

                lblX.Text = lblX.Text + instance + "<br />";

                //PerformanceCounter cnt = new PerformanceCounter("ASP.NET Applications", "Cache API Entries", instance);

                //lblX.Text = lblX.Text + ", instance=" + instance + ":value=" + cnt.RawValue.ToString() + "<br />";

            }

Open in new window

0
Comment
Question by:kruegerste
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
erik_nodland earned 500 total points
ID: 33612179
Hi

They shoulda ll be static and include the ID of your web sites. If you go to
"c:\windows\system32\inetsrv" and run the command
appcmd list site
It should show you all the sites along with their ID's. You can then figure out which one you need to pass in as the instance as it will always be the same .
HTH

Erik
0
 
LVL 4

Author Comment

by:kruegerste
ID: 33612246
Glad to hear they are static.  Looks like appcmd is an IIS 7 feature.  Can't find the equivalent for IIS5.?.?
0
 
LVL 4

Expert Comment

by:erik_nodland
ID: 33612308
Hi

Sorry I assumed it was IIS7. To get the ID from iis 5 it's easy enough to right click on the web site, then click properties. On the web iste tab next to the logging option you will see a properties tab. Click on that and at the bootom it will have the ID. IE W3SVCxxxxxxx

Cheers
Erik
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 4

Author Comment

by:kruegerste
ID: 33613334
Are you sure these "instances" are static?  Using the code snippet I provided, a random number of instances are displayed on screen at any one time for ASp.NEt Applications category.  It can be anywhere from 3 to 6 or 7 displayed.  I have 11 sites, I have never seen all 11 at one time.  
0
 
LVL 4

Expert Comment

by:erik_nodland
ID: 33618571
Hi

They will be static. Don't forget that your apps will eventually spin down to conserve resources if they have not been used for a while.  The instance name is the app domain id of the app. When hosted in IIS, this ID is made with the “metabase” path (e.g. _LM_W3SVC_1_ROOT_MYAPP). If you bring up Performance Monitor and browse for the "ASP.NET Applications" category you should see all the instances in there that are currently running. If you don't see it in the list you will probably have to browse to the app first to get it live again. You could just pick the one you need from here and see if that gets you the counters you need. They should be indentical to querying them in C#.

Thanks

Erik
0
 
LVL 4

Author Closing Comment

by:kruegerste
ID: 33629694
Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now