check_nt Commands

http://www.superk.org/index.php/Nagios_&_Windows

Performance Monitor:

Windows NT and better operating systems provided a tool for monitoring many aspects of the Windows operating system called Performance Monitor. Within Performance Monitor there is a wealth of monitoring functions available to track and graph. All of these monitoring functions are accessible through Nagios as well which makes Nagios a fantastic way of keeping track of all your Windows systems. The COUNTER variable in the check_nt command will let us connect to the Windows Performance Monitor and monitor a specific Performance Monitor function.

Here is an example:

check_nt -H <host> \
         -v COUNTER -l "\\Memory\\% Committed Bytes In Use", \
            "Committed Bytes In Use %.f %%" \
         -w 80 \
         -c 90

The above command will run a check where it connects to the Windows Performance Monitor (<host>) and read from the “\\Memory” Performance Object and the “\\% Committed Bytes In Use” Counter. The item in double-quotes directly after that (and separated with a comma) is a customized description of the results. Note the use of “%.f” in the custom description. Any custom description can be created using output commands that the C printf command uses. For instance, “%.2f” could have been used to represent the result with two decimal places. To use a ‘%’ symbol by itself in the custom description, it is necessary to escape it using another ‘%’ symbol like this: “%%” (which is output as “%”). To help clarify this, here is the syntax of the check_nt command with the COUNTER variable:

check_nt -H <host> \
         -v COUNTER \
         -l "\\<performance object>\\<counter>", \
            "<description>" \
         -w <warning> \
         -c <critical>

Here is what’s new in this command:

  1. performance object – This is the container within Performance Monitor that holds the actual performance counter to be checked.
  2. counter – This is the actual counter that will be checked for it’s current status. The current status of this counter is reported as the check command’s result.
  3. description – Optional This is the custom description field of the command. It is necessary for this description to IMMEDIATELY follow the performance object/counter field, be contained in double-quotes and separated from the performance object/counter field by a comma.

As you can see, this command is quite extensible using the COUNTER variable. Literally anything that can be monitored by the Windows Performance Monitor can now be monitored by Nagios. The advantage to do it through Nagios is that there is far less performance drain on the host computer since we are not monitoring in real-time and Nagios has the ability to notify an appropriate administrator in the event something falls out of the allowed ranges. (Another aspect of monitoring with Nagios that hopefully will be discussed in a later article is the ability to track trends for a particular host or service.)