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.

No Comments