Solved

ASP.NET Performance Counters

Posted on 2010-09-06
6
499 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Author Comment

by:kruegerste
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

9 Experts available now in Live!

Get 1:1 Help Now