Brian Ritchie's Blog

My ramblings on .NET & other development topics

News



Twitter

Blog Roll

Connect with me

September 2011 - Posts

Migrating from ASPX MVC views to Razor

 Razor-based view templates are a much cleaner way to construct MVC views in ASP.NET.  However, they were only released fairly recently with MVC3.

 If you still have some ASPX-based templates that you'd like to upgrade, Telerik has released a free tool to do just that.

Web-based Farm Monitor for your Web Farm Framework Deployment

 In my recent posts on scalability, I've mentioned the Web Farm Framework (WFF) as a solution for managing a farm of IIS servers.  It adds a nice management Server Farm management UI into the IIS Manager.

 It is a nice tool, but is only accessible via the windows interface. To make the farm more accessible, I've created a basic farm monitor MVC web site using the WFF .NET API.

 Here are a couple of screen shots of it in action:

 

 It uses a few cool features of the API:

  1. Getting a list of nodes in the farm & their status
    Microsoft.Web.Farm.WebFarmManager manager = new Microsoft.Web.Farm.WebFarmManager();            
    foreach (var farm in manager.WebFarms)
    {
        foreach (var node in farm.Servers)
        {
        }
    }
  2. CPU/Memory monitoring.  See my sparkline post to learn how to create these kinds of infographics.
    PercentageCPU = node.Counters.ProcessorTime/100;
    MemoryAvailableKBytes = node.Counters.MemoryAvailableKBytes;
    PercentageMemoryAvailable = 1.0f - node.Counters.PercentageMemoryAvailable
  3. Getting a list of running processes
    private static ServerProcess[] GetNodeProcesses(string farmName, string nodeName)
    {
        var manager = new Microsoft.Web.Farm.WebFarmManager();
        var farm = manager.WebFarms[farmName];
        var server = farm.Servers[nodeName];
        var processes = server.RunOperation(farm.CreateRunOperationOptions("GetProcesses")) as ServerProcess[];
        return processes;
    }
Download the source for the project if you'd like to take it for a spin.  Make sure the web site's application pool has enough permissions to access the web farm.

Posted: Sep 01 2011, 08:41 PM by brian_ritchie | with 7 comment(s)
Filed under: , , ,
More Posts