Check Windows Clients with Nagios and WMI

Notes

With WMI you can read and write windows settings from local or remote location. WMI is enabled by default on all microsoft computer systems, you need only to allow the remote access on it. This is very interesting for nagios, we can configure nagios to check services on remote windows hosts without installing any agent like nrpe or nsclient++. This documentation is written for Debian Wheezy with a running nagios3 configuration.

Installation

Check WMI Plus is for the WMI remote check implement on linux, Download it from here: CheckWMIPlus

First install requirements

Create directory for the check wmi plus installation, I use /opt/check_wmi_plus

Download the latest check wmi plus build from the link above and extract it:

Edit the $conf_file path in the check_wmi_plus.pl script:





Go into the etc directory and move all files from the subdirectory:

Edit the $base_dir option in the check_wmi_plus.conf configuration file:

In the same directory create the authentication file (we need this file later for the nagios service check configuration):

The windows account above must be authorized to read WMI values from the windows clients. Don’t forget to remove the read access for anyone:

The WMI check script is now ready for the nagios service checks implementation.

Configuration

This service check example describes a disk free space check for drive letter C:, the check will run at 11:00 AM one time a day from Monday to Friday. I have put all in one file.

Reload nagios configuration

Now you should see the service group in the nagios webinterface

Nagios WMI Services

This is only an example for disk free size check, read the WMI references for more information about other classes and objects.

 

Nagios Reset Availability Report

Nagios generates availability reports for configured services and hosts. Sometimes you need to reset the availability data. This documentation explains for Debian Wheezy how to reset all the nagios availability stuff, to beginn with the availability report from scratch.

Nagios Availability Report




First stop nagios process:

Nagios uses the retention.dat file for storing status, downtime, and comment information. We need to delete this file to reset the availability data:

We need to delete also the nagios archive log files:

After that start nagios, you will see that the availability report for your hosts and services starts from scratch:

Installing pnp4nagios with nagios integration

Notes

pnp4nagios is a nagios addon which collects performance data and stores it into rrd databases to generate nice performance graphs, like this one:

PNP4Nagios




We need to install the addon and modify some nagios settings to let it work. This documentation is for Debian Wheezy. For more information visit www.pnp4nagios.org.

Installation

Install the pnp4nagios

Configuration

Now we need to modify some nagios settings.

Nagios is designed to allow plugins to return optional performance data in addition to normal status data, as well as allow you to pass that performance data Nagios is designed to allow plugins to return optional performance data in addition to normal status data, as well as allow you to pass that performance data to external applications, in our case pnp4nagios, for processing. That means we need to change the process_performance_data option from the default 0 (Don’t process performance data) to 1 (Process performance data).

pnp4nagios expect the host and service performance data in the directory /var/spool/pnp4nagios/nagios (the path is set as default in the /etc/pnp4nagios/nagios.cfg file).

Set the template like below for how data is written to the performance data files.

We need to let pnp4nagios process the performance data, so change the processing command and the timeout interval for it

Create the pnp4nagios action_url service and host object. Later we can only add host-pnp or service-pnp to our services and hosts to implement the pnp4nagios graphs.

Change the npcd init.d setting and allow NPCD to start.

Add service-pnp to enable the pnp4nagios graph on your services

As example add the pnp4nagios graph to the CPU service check on localhost

Add host-pnp to enable the pnp4nagios graph on your hosts

As example add the pnp4nagios graph to the host localhost

If you have done all the configuration restart nagios and start npcd:

Now you should see the graph button on the services and hosts in the nagios webinterface:

pnp4nagtios Button

 

You need only to add the host-pnp or service-pnp template to your hosts or services like above to add the pnp4nagios graph function.