My quick Nagios client install guide

Due to changing winds at my day job I’ve been tasked to start looking into Nagios for monitoring a Windows environment. I’ve taken this as a learning opportunity and also to compare monitoring systems (aka SCOM). This blog post is not about comparing Nagios with SCOM or any other monitoring system but rather a summary of the process of installing Nagios client (NSClient++ on Windows and nrpe on Linux). Installing the server portion of Nagios is an affair for another day – as it is a rather hairy story only for the brave…

Installing a Linux client

Since I have a mixed test environment (at home) I also made use of Nagios to monitor them too. I mostly use Ubuntu/Debian based distros (like Ubuntu and Mint) so this guide will only cover them.
1. First make sure no other updates are outstanding:
sudo apt-get update
2. Then download/install the nrpe package (which includes both server and plug-in parts).
sudo apt-get install nagios-nrpe-server nagios-plugins
3. Once installed you need to configure the client so it can act as a monitoring end-point for the Nagios server. The bare minimum you have to specify is to allow the server to connect to the client. To do this you need to edit the nrpe.cfg file. By default it should be installed at /etc/nagios
sudo gedit /etc/nagios/nrpe.cfg
then search for the line that starts with allowed_hosts= and set it to the ip address for the Nagios server.
allowed_hosts=<ip address of nagios server>
4. Lastly you need to restart the agent:
sudo /etc/init.d/nagios-nrpe-server restart
Once all is done you (or the Nagios admin) need to configure the server portion. This will be covered later as it is basically the same for Linux and/or Windows clients.

Installing a Windows client

For Windows monitoring I’m using the NSClient++ agent. It is available for most Windows versions – from Windows XP to Windows 10 as well as Windows server.
1. Download the appropriate MSI version for your version of Windows from
https://nsclient.org/download/
2. Install the MSI. You can do it manually – double-click the MSI or using the command line
3. I tend to choose the the Complete option to choose
Enable common checkplugins
Enable nsclient server (check_nt)
Enable NRPE server (check_nrpe)’ with Safe mode (default)
Enable NSCA client (optional)
4. If for some reason you want to use the command line you can use something like this (which is for a silent install) – this is for the current latest x64 version 0.5.2.35-x64.
msiexec /qn /l* NSCPInstall.log /i NSCP-0.5.2.35-x64.msi /norestart CONF_CAN_CHANGE=1 CONF_NSCLIENT=1 CONF_NRPE=1 CONF_NSCA=1 ADDLOCAL=ALL

Configuring the server

This quick guide is not intended as complete reference for configuring Nagios so I’ll only be giving a summary here. By default Nagios config is found at /usr/local/nagios/etc (for version 5.x afaik).
I tend to put host configs (aka clients) in a separate directory ‘/usr/local/nagios/etc/servers’ – it just makes it easier to manage. For this quick guide I simply show how to add the ‘host’ entry and not how to configure services and any other things.
1. Create a new file for the the client/agent. I use the name ‘hostname.cfg’
2. Edit the file
example config here for a linux host
define host {
use linux-server
host_name <hostname>
alias <hostname>
address <x.x.x.x or dns name>
}
Windows host
define host {
use windows-server
host_name <hostname>
alias <hostname>
address <x.x.x.x or dns name>
}
3. After all config editing has been done I always check that changed config is okay (for typos and so on…) using the following command on the Nagios server
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
4. If all checks out you can restart the Nagios server
systemctl restart nagios.service

Summary
For now this is the quick guide. I’ll update it from time to time if I find more things that can be included.

Leave a Reply

%d bloggers like this: