Monitoring a remote Ubuntu 12.04 Linux server with Nagios3

If you have a Nagios 3 monitoring server running, there will come a point at which you will probably want to monitor a remote server as well.  This article will take you through what is needed to monitor a remote Ubuntu 12.04 Linux server.

On the remote server:
First we need to install the Nagios NRPE server and plugins

sudo apt-get install nagios-plugins nagios-nrpe-server nagios-nrpe-plugin

Next we need to configure the NRPE server:

sudo nano /etc/nagios/nrpe_local.cfg

You need to add the IP Address of the Monitoring Server and the monitors you want to configure to this file.  These will then be called by the monitoring server later.

command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 10 -c 2

Now we need to restart the NRPE server to load the new config

sudo service nagios-nrpe-server restart

On the main Monitoring Server:
You now need to install the NRPE plugins

sudo apt-get install nagios-nrpe-plugin

You now need to create a config file to be used to monitor your remote server

cd /etc/nagios3/conf.d/
sudo nano remote-host.cfg

Now you need to apply the following config:
define host{
use generic-host ; Name of host template to use
host_name ubuntu2
alias ubuntu2

# Define a command to monitor remote servers
define command{
command_name check_remote
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

# Define a service to check the load on the local machine.
define service {
service_description Current Load
check_command check_remote!check_load
use generic-service
host_name ubuntu2

# Define a service to check the disk space of the root partition
# on the local machin
define service {
service_description Disk Space
check_command check_remote!check_all_disks
use generic-service
host_name ubuntu2

# Check for missing OS updates
define service {
service_description OS Updates
check_command check_remote!check_apt
use generic-service
host_name ubuntu2

You now need to reload the montoring server config

sudo service nagios3 reload

If you browse to your Nagios URL you should now see the remote server and the monitors running.