Solved

ASP.NET Performance Counters

Posted on 2010-09-06
6
507 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET (VB) return a record 2 40
ASP Repeater control - onl;y show if flag is true 7 16
Google Maps with Webforms 1 14
Regarding swagger API 1 17
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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