IIS7 Profiling - iis-7

Is there a way to profile IIS7? (freeware?)
Number of connections
Bandwidth usage
Errors (Event Viewer?)
-...
thx, Lieven Cardoen
ps: Something similar to mssqlserver profiling

There's nothing quite like MSSQL's profiler, but a set of tools:
Perfmon will show you the # of current connections per website. Perfmon.msc, web service, current connections, select website, click add. Don't like the interactive nature of perfmon? No problem, use logman.exe, a nice CLI for perfmon.
Bandwidth usage you can get from your log files if you enable bytes sent & bytes received in your iis log files. This is also available via performance counters - web service, bytes sent/received/sec. I think the two complement each other fairly well.
IIS7 has a new feature called Failed Request Tracing. You can tell it to log on all 500's,or any .aspx page that takes 15 seconds to run, or based on event severity. It saves all of this information in an XML file for you under \inetpub so it's easily parseable, and also gives you a nice XSLT to view it in your browser and drill down if you like.
http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis7/

Try out the Administration Pack for IIS 7.0. It has:
Configuration Editor:
The configuration editor module will help you manage your configuration files. This tool is available for server administrators only. It allows you to edit any section, attribute, element or collection in your configuration file. In addition to editing these values you are also able to lock and unlock them. The configuration editor also allows you to generate scripts based on the actions you take as well as search the file to see where values are being used.
IIS Reports:
The IIS Reports module enables you to view key statistics about your website. You can also generate your own module reports to gather information relevant to you and your business. Currently you can view the output of these reports as charts and/or tables.
Database Manager:
This module is no longer part of the Administration Pack and instead is offered as a separate download in the IIS Download Center.
UI Extensions:
UI Extension modules allow you to manage existing features through IIS Manager.
The FastCGI module allows you to manage your FastCGI settings.
The two ASP.NET modules allow you to manage your authorization and custom errors settings.
Finally the HTTP Request Filtering allows you to setup rules for http request filtering.

Related

How to prevent useless disk access for Web Api endpoints?

I'm trying to optimize our .Net 4.0 Web Api Server (Classic 64 bits) and by tracing disk access I found out that whenever I hit a WebApi url (/collections/products/4452) IIS does several disk access. It tries to check for the existence of all these files and directories (using procmon.exe):
/collections
/collections/web.config
/collections/products/
/collections/products/web.config
The IIS server serves content from a UNC path (because it's a Web Farm) so all those useless disk access add up. Tracing reveals that this adds up to 8ms of latently.
I'm trying to figure out how to prevent those file accesses.
So far I have tried.
Remove all handlers except the ExtensionlessUrlHandler-ISAPI-4.0_64bit
Remove all handlers from both <system.web><httpHandlers> and <system.webServer><handlers> and write a dummy handler that returns 'Hello World'
In both cases the file checks still occur (using procmon.exe). I'm about to try and write a low level C++ module but before we go that way I wanted to ask advice here.
I suspect that before going in my handler it does some magic in aspnet_isapi.dll, but since I can't access the code, I would hope that there is some configuration I could attempt before moving forward.

Application Insights - Getting only client side data, no server data.

I have an ASP.Net MVC 4 application hosted on Windows Server 2008. I'm using Microsoft Application Insights, and it's working perfectly for client side metrics such as Client Processing Time, Custom Events, Users, Sessions, Page Views, etc. However, I cannot get any server-side metrics such as Processor Time or Available Memory. The areas are all covered by a banner that says something to the effect of "Learn how to collect server request data". When I click on the banner, it shows a blade with instructions, all of which I've already completed (the quick start).
In addition to installing the Application Insights SDK through VS 2013 (0.12.0-build17386), I've also installed and configured the Application Insights Status Monitor on the server. I've restarted IIS, and even restarted the server. Despite all this, I cannot get any server metrics. I've read the troubleshooting guide, and I've checked everything mentioned therein such as making sure the app pool identity is part of the "Performance Monitor Users" group.
I feel as though there is something I have to do to the ApplicationInsights.config file in order to either turn on and / or define the server metrics I want, but I simply cannot find any documentation on this.
Any help or suggestions would be greatly appreciated. Thanks!
No you shouldn't do anything additional with ApplicationInsights.config. Performance counters are the part of default monitoring package and almost all problems are related to that user is not the part of 'Performance Monitor Users' group, but it's not your case.
To be sure that config is correct you can check that the following module is defined in ApplicationInsights.config:
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCollector.PerformanceCollectorModule, Microsoft.ApplicationInsights.Extensibility.PerfCollector"/>
Also do you see any notifications in the StatusMonitor and/or traces/exceptions in the Diagnostic search at the application insights resource overview blade?
Ok, we've got it. There was an ApplicationInsights.config in the root folder of the application, and that was the only one I've ever looked at. At Yulia Safarova's suggestion, I discovered another one inside the bin folder. This one did NOT have the module definition specified. (It was basically empty). I copied all the contents of the one from the root into the one in the bin folder, and all the data started to flow.
If you are looking for the server data like CPU, Memory, Response rate to be displayed on the Azure Application Insight, then along with the addition of above module, also make sure that the web application Identity user is part of the administrator group on the server. and below flag is turned on in web.config
"EnableAppInsightUsageCollection" value="true"

How can I code my web app so that it knows what web server it's on?

My company has an ASP.NET web app that runs on a web farm that's load balanced by Enterprise Foundry ServerIron XL 8 hardware. For debugging purposes, we've got a page that just reports what server it's running on. Currently, we manually copy a different version of this page to each server, and hardcode the name of that server (e.g. www1, www2, or www3). What I'd like instead is to find a way for the app to determine this information itself, so we don't have to do this manual step, outside of the code itself, but I can't find any way to accomplish this.
So the question is: how can an ASP.NET app be made aware of where it's actually running?
You can do this via IIS itself.
Find the web application. In the app's main config page (features view), under IIS section you'd find HTTP Response Headers. This feature enables you to add/remove headers which need to be sent along with every response of that application.
However, you'd need tools like fiddler to be able to inspect such data.
Another option is a custom server control or user control, placed anywhere within a page which will output that information during it Render phase (as html comment). You can get using System.Environment class.
var mc_name = System.Environment.MachineName;

How do I get site usage from IIS?

I want to build a list of User-Url
How can I do that ?
By default, IIS creates log files in the system32\LogFiles directory of your Windows folder. Each website has its own folder beginning in “W3SVC” then incrementing sequentially from there (i.e. “W3SVC1”, “W3SVC2” etc). In there you’ll find a series of log files containing details of each request to your website.
To analyse the files, you can either parse them manually (i.e. suck them into SQL Server and query them) or use a tool like WebTrends Log Analyser. Having said that, if you really want to track website usage you might be better off taking a look at Google Analytics. Much simpler to use without dealing with large volumes of log files or paying heft license fees.
if you have any means of identifying your users via web server logs (e.g. username in the cookie) then you can do it by parsing your web logs and getting info from csUriquery and csCookie fields.
Alternatively you can rely on external tracking systems (e.g Omniture)
I ended up finding the log files in C:\inetpub\logs\LogFiles.
I used Log Parser Studio from Microsoft to parse the data. It has lots of documentation on how to query iis log files, including sample querys.

ASP.Net configuration file -> Connection strings for multiple developers and deployment servers

I have a team of three developers, two of whom use a standard local test database, one of whom uses his own database and there is also a server environment with a production database and a testing database.
This amounts to multiple connection strings required.
The web.config file periodically gets updated and keeps having to be changed by each developer when a source control update is performed, as well as the fact that sometimes a developer accidentally checks in his personal web.config file change with his connection string, which temporarily interrupts us after running a subsequent update from source control.
What can I change so that the web.config file can be committed/updated as often as is necessary and not result in broken connection strings for other developers or require modifications before it can be uploaded to the testing or production environments?
You might want to look at replacing the ConnectionStrings section of the Web.Config with a Config Source file, commit the LIVE set of connection strings into source control, but not include them in the actual solution.
Information on using the configSource attribute can be found in the section "Using External Configuration Files" in the document:
Connection Strings and Configuration Files
This has the advantage that developers could have their own settings that don't get checked into the main Web.Config. The potential downside is that it's yet another file that you have to worry about, and depending on how you're getting the latest version out of source control might not help (i.e. if you go to your SC client and say "Get latest" that would overwrite the file, whereas if you are in Visual Studio, right click on the solution/project and select "Get Latest" that will only get files in the projects).
For the question regarding the testing and production environments, you can make use of the Visual Studio Web Deployment Projects. With that, you can define sections in the web.config that will be replaced when you build the deployment package for the test / prod server.
You could use the Enterprise Library Data Access Block to handle your database connections. You can then define as many connection strings as you want and simply change the use key to whichever one is required. See http://www.devx.com/dotnet/Article/30910 for more information.

Resources