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

Welcome to part 3 of my series which is based around how you can use Nagios to monitor both Windows and Exchange Servers. In the previous two posts (Part 1 is located here and Part 2 is located here) – I covered the following:

Part 1

  • Setting up Nagios on Ubuntu

Part 2

  • Setting up basic monitoring for a Windows Server

In this part I would like to cover setting up some basic Exchange monitoring for Exchange 2010 DAG based servers using a script which is freely available in the Nagios community.

However before we get started there are a number of things that we need to configure on both the Exchange Server and the Nagios Server before we can effectively monitor our Exchange servers.

Installing NRPE on your Ubuntu Server

The definition of the NRPE Add-In for Nagios is as follows (taken from the Nagios Website):

NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent add-ons, so you can execute scripts and check metrics on remote Windows machines as well.

In order to remotely execute Exchange specific monitoring commands from your Nagios server (which will be via Powershell) you will need to install the relevant components of the Nagios Remote Plugin Executor (NRPE) environment within your Nagios Environment.

NOTE: It is very important that you follow these steps as closely as possible as I personally found getting NRPE to work a bit of a hassle.

Using PuTTY (see part 1) logon to the Terminal of your Ubuntu server and type in the following commands:

sudo –s cd /downloads wget tar –zxvf nrpe-2.13.tar.gz

cd nrpe-2.13 ./configure -–enable-command-args -–disable-ssl make all make install-plugin make install-daemon make install-daemon-config apt-get install xinetd make install-xinetd

You will then need to add the nrpe protocol to the Ubuntu Servers Services file.

From the Terminal Window type in the following command:

nano /etc/services

From the text editor window that appears you will need to add the following line:

nrpe 5666/tcp


When you have made the changes (as per the example above) press CTRL-O (to save the file) and CTRL-X (to exit).

You should now restart the the xinetd server using the following command:

/etc/init.d/xinetd restart

You should now check to ensure that the xinetd services (which encapsulates the NRPE service) is listening on your Ubuntu host – in order to do this you should type the following command into the Terminal window:

netstat –at | grep nrpe

You should be presented with the following output:


Configuring your Exchange Server for Monitoring

In part 2 I explained how you can install the NSClient++ monitoring agent on a Windows server in order to perform some basic monitoring. The example made use of the 32bit NSClient++, in order to Monitor Exchange 2010 you will need to download the x64 client to your Exchange servers and using the same procedure which is contained in part 2 install on your Exchange Server.

You should ensure that you also follow the process of defining the Exchange Server as a Windows Host within the windows.cfg file as you did in part 2.

Downloading Nagios compatible Exchange 2010 Monitoring Scripts

There are a number of Exchange 2010 Monitoring Scripts out in the Nagios community and by the end of this series I would like to put you in the position where I have provided you with some of my own, and hopefully enabled you to write your own (if you like writing stuff in Powershell).

However to get us started I have been using a script which was originally written by “The Angry Admin”, I have modified it slightly (to automatically detect the Host Exchange Server) – but aside from that it remains largely unchanged therefore the intellectual rights belong to “The Angry Admin”.

You should download the script to the “C:\program files\NSClient++\Scripts” folder on the Exchange 2010 server that you wish to monitor.

[ Exchange 2010 DAG Replication Status Script for Nagios – 1KB ]

When you have downloaded the script you will need to perform the following steps on the Exchange Server:

  • Set the Powershell Execution Policy to “Remote Signed” – this is done by opening an Powershell command prompt and typing the following command:

    Set-ExecutionPolicy “RemoteSigned”

Configuring the NSClient++ ini File

  • On the Exchange Server locate the “NSC.ini” (NSClient configuration file) which should be located in “C:\Program Files\NSClient++\” and perform the following:
    • Within the file locate the [NRPE] section and ensure that the following entries are either present or uncommented (e.g. the “;” is removed)
    allowed_hosts=<Nagios Server Address> # e.g. in my configuration it’s allowed_hosts=
    • Within the “NSC.ini” you will find a section called [NRPE Client Handlers] – rename this to [NRPE Handlers] and then add:
    check_exrep=cmd /c echo scripts\exrep.ps1 | powershell.exe -command -
    • When you have made the above changes, save the file and then restart the NSClient++ Service from the Windows Services manager

Configuring the Exchange Service Monitoring within Nagios

We are now done with the configuration on our Exchange Server, and now need to turn our attentions back to the Ubuntu Nagios Server. In part 2 of this series I explained how you can add Service Monitoring to a Windows Service – this made use of two files:

  • Windows.cfg
  • Commands.cfg

Each of which you can download via Filezilla to your local machine (into the Nagios_Configuration_Files directory which we setup in part 2).

To execute the Powershell script file which we placed on our Exchange server we need to modify the above files (using Notepad++ as described in the previous part).

In the windows.cfg file add the following Service definition:

define service{
    use            generic-service
    host_name        prod-ex2010-01.prepad.local ;This should be changed to the host definition of your Exchange Server
    service_description   Exchange Database Status
    check_command    check_exrep

When you have made the above modifications save them in Notepad++ (but don’t upload the file to the Nagios server just yet!)

Open the “Commands.cfg” file in Notepad++ and ensure that the following lines are present within the file – if they are not you should add them:

# 'check_nrpe' command definition
define command {
    command_name check_nrpe
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 180 -c $ARG1$

Then add the following command definition:

define command{
    command_name    check_exrep
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 120 -c check_exrep

When you have added the above, you should save the file, and then using Filezilla upload the files to your Ubuntu Server to the “/usr/local/nagios/etc/objects directory”.

When you have done the above, restart the Nagios Server on the Ubuntu host from your PuTTY session via the following command for the changes to take effect:

/etc/init.d/nagios restart

When the above changes have been made you should see the following within the Nagios Web interface:


A clearer view looks like the following:


In the next part

In the next part of the series I would like to cover some custom Exchange 2010 monitoring scripts that make use of the NRPE interface which will give you some ideas on how you can develop an enriching monitoring environment.


  1. Hi Andy,

    should there be a “cd nrpe-2.13” command between these two commands:

    tar –zxvf nrpe-2.13.tar.gz

    ./configure -–enable-command-args -–disable-ssl

    1. Hiya Michael, yep – you are correct – I have updated the article above. Once again thank you!

  2. I don’t know if I did something wrong or not but I could not get this to work until I enable the NRPEListener.dll at the top of the NSC.ini configuration file on my exchange server.

  3. Can you update this for NSC++ 4.2?? a lot of the settings no longer exist so I cannot figure out how to make this work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.