Solved

ASP.NET Performance Counters

Posted on 2010-09-06
6
509 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Form Data Disappears Using Back Button 4 63
Validation for a field in asp.net 3 29
Fastest way to get file count in MS Server 2012 3 34
history of pages 7 48
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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