Nagios

Monitoring Windows Machines


Up ToUp To: Contents
See Also See Also: Quickstart Installation Guide, Monitoring Publicly Available Services

Introduction

Introduction

This document describes how you can monitor "private" services and attributes of Windows machines, such as:

Publicly available services that are provided by Windows machines (HTTP, FTP, POP3, etc.) can be monitored easily by following the documentation on monitoring publicly available services.

Note: These instructions assume that you've installed Nagios according to the quickstart guide. The sample configuration entries below reference objects that are defined in the sample config files (commands.cfg, templates.cfg, etc.) that are installed if you follow the quickstart.

Overview

Monitoring private services or attributes of a Windows machine requires that you install an agent on it. This agent acts as a proxy between the Nagios plugin that does the monitoring and the actual service or attribute of the Windows machine. Without installing an agent on the Windows box, Nagios would be unable to monitor private services or attributes of the Windows box.

Steps

There are several steps you'll need to follow in order to monitor a new Windows machine. They are:

  1. Installing the NCPA Agent on Windows
  2. Configuring NCPA
  3. Start Monitoring
    • Active Checks (check_ncpa.py)
      • Installing the check_ncpa.py plugin
      • Creating new command, host and service definitions for monitoring the Windows machine
      • Restarting the Nagios daemon
    • Passive Checks (NRDP)
      • Add checks to your ncpa configuration
      • Configure your NRDP settings

Installing the NCPA Agent on Windows

Installing the NCPA Agent

Before you can begin monitoring private services and attributes of Windows machines, you'll need to install an agent on those machines. We recommend using Nagios cross-platform agent, which can be found at https://www.nagios.org/ncpa/.

These instructions will take you through a basic installation of the NCPA agent, as well as the configuration of Nagios for monitoring the Windows machine.

  1. Download the latest stable NCPA agent to the system you are installing it on from here: https://nagios.org/ncpa/#downloads.
  2. Double click on the ncpa-x.y.z.exe file to start the installation of the agent. Follow through all of the required steps as described in our NCPA documentation here: https://www.nagios.org/ncpa/getting-started.php#windows

Configuring NCPA

Most of the configuration will be located in the C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg file. See detailed instructions on how to configure the NPCA agent on Windows in our Help Documentation. After modfying the configuration files and saving them, you will need to restart the NPCA services, so that changes can take effect. You can do this from the services administration panel (in the GUI) or from the command line (CMD Prompt):

net stop ncpalistener
net start ncpalistener

net stop ncpapassive
net stop ncpapassive

Start Monitoring


Find our what you want to monitor

Knowing what you want to monitor will help you figure out what sort of checks you will need NCPA to perform. This could include your own custom plugins - or just data that NCPA can get itself. That is entirely up to the end user. For this example we will monitor the following using only NCPA built-ins:

There are many more endpoints, but you can read the help documentation to see more options.


Decide the kind of check to use

Once you've decided what to monitor, you can choose how to monitor it. There are two types of checks you can use. Active checks are ran using a plugin on the Nagios Core side, which will put most of the load on the server. If you have a lot of checks and want to move some of the load or you have a system that sometimes drops connections, you might want to use a passive check. Passive checks run on the client side and send the check results to Nagios Core for processing. NCPA can do both kinds of checks, so it's up to you to choose.


Active Checks (check_ncpa.py)

The steps below will cover some basic information on how to install the check_ncpa.py plugin, create a new command, host, and service definitions in Nagios Core.


Installing the check_ncpa.py plugin

Run the following commands from the command line on your Nagios server:

cd /tmp
wget https://assets.nagios.com/downloads/ncpa/check_ncpa.tar.gz
tar xvf check_ncpa.tar.gz
chown nagios:nagios check_ncpa.py
chmod 775 check_ncpa.py
mv check_ncpa.py /usr/local/nagios/libexec

Note: If you have a different path to the nagios plugins directory, you will need to modify the last command.

To verify the version of the check_ncpa.py plugin, run the following command from the command line:

/usr/local/nagios/libexec/check_ncpa.py -V

You should see something like this:

check_ncpa.py, Version 1.1.0

Creating new command, host and service definitions for monitoring the Windows machine


Create the check command definition

Create the check_ncpa command in your configuration files for Nagios Core, normally they are located in /usr/local/nagios/etc - you may have a commands.cfg file you will want to put this command in. The command below will allow us to pass most of the arguments in with $ARG1$, allowing it to be more dynamic.

define command {
    command_name    check_ncpa
    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}


Create Nagios checks

You can create the checks in a config file in /usr/local/nagios/etc. For this example we will create a config file called ncpa.cfg with the following defined:

define host {
    host_name               NCPA 2 Host
    address                 192.168.1.10
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M system/agent_version
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    contacts                nagiosadmin
    notification_interval   60
    notification_period     24x7
    notifications_enabled   1
    icon_image              ncpa.png
    statusmap_image         ncpa.png
    register                1
}

define service {
    host_name               NCPA 2 Host
    service_description     CPU Usage
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               NCPA 2 Host
    service_description     Memory Usage
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M memory/virtual -w 50 -c 80 -u G
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               NCPA 2 Host
    service_description     Process Count
    check_command           check_ncpa!-t 'mytoken' -P 5693 -M processes -w 150 -c 200
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}


Replace the -t 'mytoken' with your own token. This will tell Nagios to perform active checks and will create a host called "NCPA 2 Host" with checks for CPU Usage, Memory Usage, and Process Count.

Restarting the Nagios daemon

Restart the Nagios service and you should see pending hosts/services appear. Once they do their initial checks, you should see your NCPA data in Nagios.

Passive Checks (NRDP)

In order for passive checks to work, you have to configure your passive service to actually send the checks. By default in new installs of NCPA 2, no passive handler is configured. If you installed on Windows and set up NRDP during the install process then you will already have a configuration set up. However, it would be a good idea to take a closer look at your configuration just in case.


Add checks to your ncpa configuration

Add a new NCPA configuration file to the ncpa.cfg.d directory located in the base NCPA installation directory. Use the following outline for passive checks to send to the NRDP server of your choice.

[passive checks]
%HOSTNAME%|__HOST__ = system/agent_version
%HOSTNAME%|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg
%HOSTNAME%|Memory Usage = memory/virtual --warning 80 --critical 90 --units Gi
%HOSTNAME%|Process Count = processes --warning 300 --critical 400


By default, passive checks are ran on 5 minute intervals, however with NCPA 2 you can now define a check interval in seconds by appending |interval to the left side of the passive check definition. An example of a CPU check that would be performed every 30 seconds is below:

%HOSTNAME%|CPU Usage|30 = cpu/percent --warning 60 --critical 80 --aggregate avg


Configure your NRDP settings

In Nagios Core, you would need to install and configure NRDP manually. Follow the steps, outlined in the "NRDP In Nagios Core" section of the NRDP - Overview document.

Once you have your settings. Edit your ncpa.cfg file to look something like the following:

[nrdp]
parent = http:/<nrdp address>/nrdp/
token = nrdptoken
hostname = NCPA 2 Host


Enable the nrdp handler in the [passive] section of your config:

[passive]
handlers = nrdp


Restart the NCPA Passive service

Restart the ncpa_listener service on the Windows machine.

You should start receiving passive check results immediately after the service has been restarted. A service restart is always required when making changes to the passive check configuration