Often times if you administer a web farm, or develop for a web farm, you want to know which node you’re currently on. This is useful is you want to know if your load balancers are balancing with the algorithm that you expect, or if you want to troubleshoot why a website fails just some of the time.
A couple years ago I blogged about an easy way to include the node information on a page. You may include it as an HTML comment, or in a separate page, or temporarily include it on the page during development.
A while back I wrote a simple Http Module that I use for many sites that I administer. It display similar information and can be called at any time to get details on the server node and the site. I wanted to make it available here.
Basically it registers as an HTTP Handler in IIS 6 or 7.x at the server level so that when you call www.yoursite.com/siteserverdetails.axd, it displays the server node that you are on along with the IIS site name.
I find that the IIS site name is useful because I often maintain different instances of the sites that I swap out during deployment. (I’ll cover site instances in more depth later this year).
The download has a tiny file call SiteServerDetails.dll which needs to be registered in the GAC, and a file called install.bat, which I’m sure you can guess what it does. It’s an installer for IIS7.x only. If you want to install on IIS6, just review install.bat to see which steps were taken.
Install.bat has been tested “on my machine” so I can’t promise that it will work on all servers, but it’s simple and straight forward, and it doesn’t hurt to run it multiple times. If something is already installed, it will just provide a message that it was already copied or registered.
After it’s installed, just visit www.yoursite.com/siteserverdetails.axd and voilà, you’ll have server and site information available to you.
The nice thing about a HTTP Handler is that it’s only called if you call the specific path—in this case siteserverdetails.axd—so this is safe and doesn’t have any overhead for the operation of your website.
Note, this does provide some information that anyone can view if they figure out the URL, so if you feel that this is too revealing, you can password protect it using standard .NET forms authentication. You will need to password protect it for every site, so you can either do so on every site, or else register SiteServeDetails only on the sites that you need it on.
One caveat is that this works with ASP.NET v2.0 and greater. If you still have a v1.1 site (I feel for you) then this will not work. It won’t hurt the rest of the site to have it installed, it just won’t load correctly.
Next week I’ll make another tool available that works with URL Rewrite (in IIS 7.x only) that adds an X-Header to the HTTP response so that tools like Firebug and Fiddler can view similar information on every file, including images.