There are different methods for monitoring Windows from a Nagios environment. The easy approach is to use the check_nt command. In this article, you’ll find out how to configure the Nagios Server and use the check_nt command to monitor a Windows environment.
Requires Free Membership to View
Getting started with NSClient++
The first step to monitoring your Windows environment is to download and install the NSClient++. You can find it at http://sourceforge.net/projects/nscplus. Before
you click the download link, check which version of the software you need. The default download
gives access to a 64-bit version. If you need to run NSClient++ on 32-bit Windows, you need to
download the 32-bit MSI from the Files section of the download page.
After downloading the NSClient++, you need to start the Windows services interface and configure the NSClient++ service to start automatically. Also, you need to make sure that the service logs in with the local system account, and can run automatically from the desktop. The final step is to check the Windows firewall. NSClient++ runs on port 12489, so make sure that it is open in your firewall.
Configuring the Nagios Server
After setting up the Windows part of the configuration, you also need to configure the Nagios
server. First, you have to make sure the check_nt command is defined in
/etc/nagios/objects/commands.cfg. There's also a small change to apply -- the default
configuration doesn't use a password, so at the end of the command line, add -s nagios (see
Example 1), to tell the check_nt command to use the default password "nagios."
# 'check_nt' command definition
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ -s nagios
}
Example 1: Add -s nagios at the end of the command line to tell the check_nt command to use the default password.
Next, in /etc/nagios/objects/templates.cfg, you need a template that defines how Windows hosts should be configured. Example 2 below shows what this definition looks like by default:
define host{
name windows-server ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, Windows servers are monitored round the clock
check_interval 5 ; Actively check the server every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each server 10 times (max)
check_command check-host-alive ; Default command to check if servers are "alive"
notification_period 24x7 ; Send notification out at any time - day or night
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
hostgroups windows-servers ; Host groups that Windows servers should be a member
register 0 ; Don't register this, it is just a template
}
Example 2: # Windows host definition template - This is not a real host, just a template!
After verifying that the template exists, you need to tell Nagios that it should also monitor Windows. You can do that by uncommenting the cfg_file line (Example 3), which tells Nagios to look at the windows.cfg file:
# Definitions for monitoring a Windows machine
cfg_file=/etc/nagios/objects/windows.cfg
Example 3: Uncommenting the cfg_file line.
Once you've done this, you can define the Windows host to be monitored. This is something that needs to be done for every Windows host that should be monitored. To do this, you need a define host section (Example 4) in the windows.cfg file:
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.1.54 ; IP address of the host
}
Example 4: Define host section
Now, the only remaining step to configure Nagios for Windows is to define the services that you want to monitor. This also happens from the windows.cfg file. You can find an example of two of these services below (Example 5):
#########################################################################
#########################################################################
#
# SERVICE DEFINITIONS
#
#########################################################################
#########################################################################
# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name winserver
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name winserver
service_description Uptime
check_command check_nt!UPTIME
}
Example 5: Define the services that Nagios should monitor.
Read the remaining contents of the windows.cfg file to find out which service checks are available, and make sure to enable all services you need. Once you've done that, you can save your changes and restart the Nagios server, using service nagios restart on the Nagios host. This activates the changes, and from that point on, you'll be able to monitor services on Windows hosts from the Nagios interface.
In this article you've learned how to configure Nagios for Windows, and how to monitor basic
Windows server parameters using the check_nt program. Using the check_nt option gives
you a good start, but doesn't allow you to monitor advanced parameters. For a more in-depth look,
you need NRPE. In an upcoming article, you'll learn how to configure NRPE to provide you with the
exact details you need.
About the author: Sander van Vugt is an independent trainer and consultant living in the
Netherlands. Van Vugt is an expert in Linux high availability, virtualization and performance and
has completed several projects that implement all three. He is also the writer of various
Linux-related books, such as Beginning the Linux Command Line, Beginning
Ubuntu Server Administration and Pro Ubuntu
Server Administration.
This was first published in June 2011
Data Center Strategies for the CIO

Join the conversationComment
Share
Comments
Results
Contribute to the conversation