« Previous Next »

Thread: Querying farm statistics programmatically

Last post 10-14-2009 2:45 PM by MarcelMeyer. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 10-14-2009, 11:57 AM

    Querying farm statistics programmatically

    Hi there, Is there a way to query and get stats (the metrics that you get using the Monitoring and Management option, such as the health status, requests per sec, response times etc.) programmatically? The Microsoft.Web.Administration API does not seem to support it. Thank you in advance, Marcel
  • 10-14-2009, 12:28 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: Querying farm statistics programmatically

    You can get it via Microsoft.Web.Administration - please see %windir%\system32\inetsrv\config\schema\arr_schema.xml for the name of the properties etc.  Also, in ARRv2 RTW, these statistics are also going to be available via performance counters.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 10-14-2009, 2:45 PM In reply to

    Re: Querying farm statistics programmatically

    Thank you Anil. It proved to be quite easy once I had the schema sorted. Below is some demo code on how to do it. var iis = new ServerManager(); var result = iis.GetApplicationHostConfiguration(); var webFarmsSection= result.GetSection("webFarms"); var status = from farm in webFarmsSection.GetCollection() from server in farm.GetCollection() let arrSection = server.GetChildElement("applicationRequestRouting") let countersSection = arrSection.GetChildElement("counters") select new { Name = farm.GetAttributeValue("name"), ServerAddress = server.GetAttributeValue("address"), IsServerHealthy = countersSection.GetAttributeValue("isHealthy"), TotalRequests = countersSection.GetAttributeValue("totalRequests") };
Page 1 of 1 (3 items)
Microsoft Communities