?
Solved

ASP.NET Performance Counters

Posted on 2010-09-06
6
Medium Priority
?
520 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 2000 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
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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