Installing Nagios on Ubuntu Server 11.10 then Monitoring Windows and Exchange Servers–Part 2–Setting up basic Windows Server Monitoring…

by Andy Grogan on January 11, 2012 · 5 comments

in Linux, Linux with Exchange, Nagios, Ubuntu

In the first part of this series I covered how you can get a working instance of Nagios Core on a Ubuntu VMWare server within your environment. What I would like to cover in this part is how you can begin to perform some basic monitoring on a Windows Server within your infrastructure using the Nagios Core Server that you configured in Part 1.

Installing the Monitoring Client on Windows Server that you wish to manage

Log onto the Windows Server that you wish to manage. You will need to download the NSClient++ from the following location: – you will need to select the correct architecture which fits your client system (Win32 or x64) – and I recommend that you download the MSI file rather than the zip (mainly for simplicity and it is easier to build an automated deployment around).

When you have the MSI file on your server you will need to perform the following steps:

Double click on the “NSClient++-0.3.9-Win32.msi” file which will then present you with the installer welcome screen (below) – click on the “Next” button


On the EULA screen, tick the “I accept the terms of the license Agreement” option and then click on the “Next” button – see below:


Next you will be asked to choose the components that you would like to install – these include the actual program binaries, configuring a Windows Firewall exception should you wish, registering the program to run as a service (recommended) and a number of functional plugins (which enable a number of checks on your system and the ability to communicate with a number of monitoring systems which support various listeners include Nagios).

For the purposes of this article I have chosen to install all components (as per the screenshot below) – when you are happy with your own choices click on the “Next” button:


As this is a new install the next screen is not really that relevant, however suffice to say that if you have a pre-existing configuration file in the installation location (for example during a client upgrade) – you will be prompted if you would like to use the existing file or create a new one. In our case we can just click on the “Next” button:


The next screen asks you to complete some information about you Nagios server (e.g under the “Allowed Hosts” section – within the IP address text box – you can provide a number of hosts that the agent can report to – in our case this will be the IP address of your Nagios Server).

In the NSClient Password section you should provide a password to secure (remember not encrypt) communications  between the client server and the Nagios server. This is used by the “check_nt()” function (more on this later) for Service Calls. In the “Modules to load” section I have ticked all options – however you should ensure that the “Enable nsclient server (check_nt)” is enabled and then click on the “Next” button – see below:


You will now be ready to install the NSClient on the server that you wish to monitor – click on the “Install” button – see below:


When setup has completed you will be asked if you wish to Start the NSClient Service (ensure that the Start Service is ticked) – you are of course welcome and encouraged to donate to the project as it does provide a unique service to folks like us – however when happy click on the “Finish” button:


Configuring Nagios to Monitor your Windows Server

Now this is where things get a more little involved as in order to setup the Windows monitoring configuration we need to make a few changes to some of the Nagios configurations files which are located on the Ubuntu server that we created in part 1.

Firstly I recommend that you setup sFTP to connect to the Linux file system on your Nagios Server (remember the OpenSSH server that we installed in part 1?). In order to do this, you need an FTP client that supports sFTP connections – you may already have a weapon of choice in this area – but if you don’t, I personally recommend Filezilla (as it is free and also what I have been using for a number of years – therefore this article will focus on using Filezilla from this point onwards – so you might need to substitute some steps to reflect your own client).

Secondly, as we will be editing the Nagios Configuration files within a Windows environment (don’t laugh Linux peeps)– you will need a text editor that supports both the Unix and ANSI formats – one suggestion that I have is Notepad++ which, again I have been using for a number of years and is pretty cool.

Setting up Filezilla to connect to your Nagios Server

Firstly you will need to download and install Filezilla onto your local machine. When you have installed the FTP client – launch it and then from the “File” menu select “Site Manager” – see below:


Within the Site Manager click on the “New Site” button and then on the “General” tab complete the required information as per your configuration – you should ensure that the “Protocol” option is set to “SFTP – SSH File Transfer Protocol”.

You should also ensure that the “Logon Type” is set to “Normal” and that you provide the username and password for your Ubuntu administrative user – see below:


Before you connect to your Ubuntu server I recommend that on your local Windows machine you create a folder called “Nagios_Configuration_Files” – this will naturally be used to store local copies of the Nagios configuration settings – which you can edit locally using Notepad++ and then upload them back to your server.

Key Nagios Configuration Files

In order to setup basic Windows monitoring from your Nagios server there are three principle configuration files that you will be working with – these are defined with the changes that you need to make below:

  • nagios.cfg – located in /usr/local/nagios/etc
    This is the main configuration file for the Nagios server – there is only one change that needs to be made within this file, and once that has been made it is recommended that you make no further modifications (unless of course you have been doing some reading up on the product and want to do something fancy).

    Using Filezilla (sic. to connect to your server) – navigate to the path that is shown in bold above and download the nagios.cfg file to the local “Nagios_Configuration_Files” location that you created above – see below


When you have downloaded the file – open it using Notepad++ and then uncomment (e.g. remove the #) the following entry in the file:


This tells Nagios that we will be monitoring Windows hosts, and therefore the “windows.cfg” and services files should be queried.

When you have done the above, save the file in Notepad++ and then via Filezilla upload the file back to the /usr/local/nagios/etc directory.

  • commands.cfg – located in /usr/local/nagios/etc/objects

    This configuration file tells Nagios what monitoring commands it should expect to have executed against it.
    Again this file should only be edited when required and there is only one change required within the file for the initial setup.

    As before with the Nagios.cfg file, download the commands.cfg to your local “Nagios_Configuration_Files” directory and then open it within Notepad++

    Look for the following line:

# 'check_nt' command definition

You will see the following entry within the ‘check_nt’ define command block:

command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$

You need to add the –s switch with the password that you configured for the NSClient (in the first bit of this article) on your Windows Server – therefore the entry within the commands.cfg file should look like the following:

command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s password -v $ARG1$ $ARG2$

When you have made the changes to the file, save them in Notepad++ and then using Filezilla upload them back to the /usr/local/nagios/etc/objects to your Nagios Server.

  • windows.cfg – located in /usr/local/nagios/etc/objects

    It is within this configuration file that you will define all of your Windows hosts and the Services that you wish to monitor. As before download this file to your local “Nagios_Configuration_Files” directory.

    When you open the file in Notepad++ you will be presented with a number of entries which represent a sample configuration – you can remove everything below the HOST GROUP DEFINITIONS (NOT NOT REMOVE THE HOST GROUP DEFINITIONS SECTION!!!!) and replace them with the following configuration (I have included some comments inline below which describe what each configuration entry does):


define host{
    use            windows-server    ; Inherit default values from a template
    host_name    prod-dc-01.prepad.local ; This should be the FQDN of the server that you wish to monitor   
    alias        Prep AD Domain Controller Number 1    ; This should be a descriptive name for the monitored server
    address    ; IP address of the monitored host


define service{
    use            generic-service
    host_name        prod-dc-01.prepad.local ; Replace this entry to reflect the host name in the define host section
    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        prod-dc-01.prepad.local
    service_description    Uptime
    check_command        check_nt!UPTIME

# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
    use            generic-service
    host_name        prod-dc-01.prepad.local
    service_description    CPU Load
    check_command        check_nt!CPULOAD!-l 5,80,90

# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
    use            generic-service
    host_name        prod-dc-01.prepad.local
    service_description    Memory Usage
    check_command        check_nt!MEMUSE!-w 80 -c 90

# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
    use            generic-service
    host_name        prod-dc-01.prepad.local
    service_description    C:\ Drive Space
    check_command        check_nt!USEDDISKSPACE!-l c -w 80 -c 90

# Create a service for monitoring the Netlogon service
# Change the host_name to match the name of the host you defined above

define service{
    use            generic-service
    host_name        prod-dc-01.prepad.local
    service_description    Netlogon Service
    check_command        check_nt!PROCSTATE!-d SHOWALL -l lsass.exe

When you are happy with the file, save it within Notepad++ and then upload it to your Nagios Server (ensure that the directory is /usr/local/nagios/etc/objects).

Committing the Configuration to your Nagios Server

Each time you modify any Nagios configuration file you need to “commit” the settings to the server so that they will take effect. In order to do this open up a PuTTY session to your server, logon and then type in the following command:

sudo /etc/init.d/nagios restart

This is demonstrated below:


After about 90 seconds you should see the following within the Nagios web console:


If you drill down into your new host – you should see the following:


Sample Configuration Files

To accompany this series I have provided my own Nagios configuration files direct from my lab environment for download below.
Please remember that these are specific to my own installation and should only be used for reference (should you get stuck) – these are also based upon the default file set that is provided by Nagios – and therefore the intellectual rights belong to the developers of Nagios.

[ Nagios Sample Windows Monitoring Files – 15KB ]

In the next part

In the next part of this series I will show you how you can use Nagios to monitor your Exchange Servers.
If you should have any questions about this article please post them in the comments section and I will get back to you.


{ 5 comments… read them below or add one }

Bradley Marks January 16, 2012 at 6:30 am

Thanks so much for this 🙂


Kitson March 30, 2012 at 2:07 pm

Thanks In advance
I need some help i cant see to upload files it keeps telling me i don’t have the correct permission.


Andy Grogan March 30, 2012 at 2:16 pm

Hiya Kitson, are you using the root account within Filezilla?


Rama September 9, 2012 at 9:27 am



anuj kumar January 27, 2015 at 6:21 am

nice one …..very good


Leave a Comment

Previous post:

Next post: