Farm Monitor v0.2

Introduction

This utility is a simple monitoring and administration tool for small farms of Windows servers. The monitoring aspect uses the Windows Management Instrumentation (WMI) interface for retrieving information about the remote servers. For the administration side, command lines can be configured to be executed for the selected host.

NOTE: As you can see from the version number this is still very much a work in progress. I have some key features I'd like to add, such as aggregations, and so it's probable that a breaking change will still occur before reaching a v1.0 release. I'll try and maintain the existing file format but can't guarantee it.

Background

The genesis of this tool was almost 10 years ago when I started working in the HPC (High Performance Computing) arena. We had a number of environments that consisted of application servers for orchestration and blades for raw computation duties. Although the Sysinternals tools like PsExec, PsList, etc. are great for automation and ad-hoc command line use there was still a fair amount of other ad-hoc monitoring and administration to do which involved flicking between servers. This was especially true outside the production environment where there was no company-wide monitoring running.

Naturally time has moved on a lot since then. At that time there were very few free tools available that exposed WMI, especially on Windows 2000. My own command-line tool, WMI Command, was the first phase of this project as it allowed me to wrap the COM based WMI library in C++ and explore it.

With PowerShell now more readily available and well known it is even easier to consume WMI based content, which is great for ad-hoc querying. However I still thought a GUI based approach was still viable once you'd worked out what sort of queries you wanted to run continuously, hence this tool was born.

Hosts

When the application starts for the first time the main view will be configured with a single host - the local one. More hosts can be added, renamed and removed from the main view. They can also be reordered so that hosts can be grouped according to environment, role, or whatever. Each host has both a specific "environment" attribute and a more general purpose "description" attribute to aid with grouping and identification. Right-clicking on a host shows the context menu with these options, along with copying the host's name to the clipboard, and showing installed services and running processes.

When entering the details for a host, these are the fields:

Field Description
Host name The name (or IP address) for the host.
Monitor? Tick this box if you want the host to be queried.
Alternate logon The alternate credentials to use when querying the host.
Environment The name of the environment the host belongs to.
Description A short description of the host, such as its role.

Note: You can use the "Check" button to run a DNS query against the host name to help validate it.

Tools

For administration purposes a number of external tools can be configured which are accessible from the context menu (right-click) of a host. Each tool is configured as a command-line where the selected host name will be substituted for the ${HOSTNAME} token on execution, e.g.

mstsc /f /v ${HOSTNAME}

Out-of-the-box there are a couple of default tools configured: one to open a full-screen remote desktop via the MSTSC tool, and another to continuously PING the host, which is useful when restarting it.

WMI Queries

The main view is used to display information about the configured hosts via WMI queries. The monitoring is currently done manually by using the "View | Refresh" option (or hitting F5) and will sequentially poll each server in-turn to update the data. Hosts which are temporarily off-line or that you do not want to monitor can be marked as such from the host details dialog.

The icon next to a hostname displays its current status. It starts off as a question mark to show that its status is unknown. When the view is refreshed and the WMI queries are run it will update to either a green or red circle depending on whether or not the host was contactable to service the queries.

The default WMI queries are just examples of what can be used and should work fine against most hosts. They show the total and free memory available, the total and free disk space for drive C:, and the date/time when the machine was last rebooted. The final column, "Last Error", will show any major error that occurred trying to connect to the host, such as if authentication failed. Errors that only occur for some queries, e.g. no E: drive exists, will be reported in the specific column as #N/A or #ERR.

If a host requires different credentials to attach to it, then they can be configured in the host details dialog. Alternate credentials will only be prompted for once and then cached indefinitely.

Query Attributes

From the "View | Queries..." dialog you can manage the queries that are executed against every host marked for monitoring. You can add, copy, update or remove queries along with re-ordering them. Double-clicking the title is another way of launching the editor for the selected query.

When creating or editing a query the following fields are used to define it:

Field Description
Query Template A selection of common pre-defined queries.
Column Heading The text to use in the column heading of the main view.
WMI Class The name of the WMI class to query on. By default FarmMonitor only queries for objects under the \root\cimv2 name space.
WMI Property The name of the property from the WMI class specified above that you want to display.
Formatting Choose how the value of the WMI property should be displayed. The various options are explained below in Formatting Values
Filter Property The name of an optional WMI property on which to filter for a specific object in the set.
Filter Property Value The value to match the above optional Filter Property on, if specified.

A query will by default display only the first object in the result set. For classes like Win32_OperatingSystem where there is only a single object it doesn't matter. But for objects like disk drives, which are queried using Win32_LogicalDisk, it matters as you need to pick the specific drive you're interested in. This is done with the optional Filter Property/Value fields available at the bottom. For example, to pick disk drive C: you would want to match on a Filter Property of "DeviceID" and a Filter Value of "C:".

To find out what WMI classes and properties are available you'd need to consult the MSDN. I normally use a tool like WMI Command or PowerShell to explore the query first, and then I know what I want to configure for monitoring in Farm Monitor.

Formatting Values

Although the WMI interface is COM based not all values come through using the most natural COM types. For example really big numbers, like the amount of memory in bytes, is not passed as a 64-bit integer, but as a string. Date/times are another example of values passed as strings. As such you need to provide a hint to the query about how the value needs formatting.

The default format for any value is a simple string as most other types can be coerced into that by the COM runtime. However there are some custom formats that can be used to scale and add units to make values more readable. In particular some larger values are represented in kilobytes, rather than bytes, and therefore need to be scaled differently. This difference in scale is not automatically detectable.

Name Description
String Display the value as a simple string.
Date & Time Interpret the value as a WMI format date/time and display in the local date & time format.
Bytes Display the value (specified in bytes) as a whole number of bytes.
Kilobytes Display the value (specified in bytes) as a whole number of kilobytes.
Megabytes Display the value (specified in bytes) as a whole number of megabytes.
Gigabytes Display the value (specified in bytes) as a whole number of gigabytes.
KB as MB Display the value (specified in kilobytes) as a whole number of megabytes.
KB as GB Display the value (specified in kilobytes) as a whole number of gigabytes.

License & Warranty

This application is freeware - you get what you pay for, nothing more, nothing less.

Source Code

The full source code (C++) is available from my web site listed below.

Contact Details

The "Help | About" dialog also contains my contact details. Please check the web site for updates.

Email: gort@cix.co.uk
Web: www.chrisoldwood.com

Chris Oldwood
29th March 2016