How to Monitor Linux Server Using Nagios Core And NRPE

Nagios is the leader and industry standard in enterprise-class monitoring solutions. Nagios provides two monitoring tools Nagios Core and Nagios XI.

Nagios Core is a free and open source tool that allows you to monitor your entire IT infrastructure to ensure hosts, services and applications are functioning properly. For more information, you can visit the website of Nagios. This article is intended for use by Nagios Administrators who wish to monitor Linux servers with Nagios Core using the linux NRPE agent.

The linux NRPE agent must be installed on the target linux machine and configured before Nagios Core can monitor system metrics, services, processes, or performance data on the target machine. NRPE is able to perform two types of checks, Direct and Indirect. In Direct checks the Nagios server executes check_nrpe which then connects to the NRPE daemon which is running on the client. The NRPE daemon then will execute the command that was requested from the Nagios server.  The command could also execute any script on the client whether it be a bash shell script, a Perl script or any other type of script.

If you still didn’t install Nagios Core , check the following articles.

In this article we will show you how to install and configure NRPE AGENT in the remote server and how to add the host to Nagios Core.

Installing and Configuring NRPE On The Remote

Linux Machine

Download the Linux NRPE agent to the /tmp directory on the Linux server you wish to monitor.

cd /tmp

For RHEL/CentOS 5+, Fedora 14+, SLES 11+, OpenSUSE 11+, Ubuntu 12+, and Debian 6+:


For RHEL 4 & CentOS 4 (el4):


Unpack the installation archive you just downloaded:

tar xzf linux-nrpe-agent.tar.gz

Enter the newly created agent sub-directory:

cd linux-nrpe-agent

You need to run the wrapper script as root (if using Ubuntu you’ll need to either run sudo -i to run as root):

sudo ./fullinstall

The script will stop to prompt you once, to ask for the IP address(es) for your monitoring server(s).

You will need to type the ip address, of your Nagios server and then press enter. This will allow connections from your monitoring server to the agent process.


By default there are several commands that are pre­configured for NRPE in the /usr/local/nagios/etc/nrpe.cfg file.
They are listed here.

command[check_users]=/usr/local/nagios/libexec/check_users ­w 5 ­c 10 
command[check_load]=/usr/local/nagios/libexec/check_load ­w 15,10,5 ­c 30,25,20 
command[check_hda1]=/usr/local/nagios/libexec/check_disk ­w 20 ­c 10 ­p /dev/hda1 
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs ­w 5 ­c 10 ­s Z 
command[check_total_procs]=/usr/local/nagios/libexec/check_procs ­w 150 ­c 200

In order to add additional commands you will need to construct them in the same format and add them to this file. If any changes are made the xinetd daemon must be restarted.

Configuring Nagios Core to Monitor the Linux Host

You have now successfully installed and configured the monitoring agent and required plugins on the Linux server. In order to monitor the server using Nagios Core, you will need to add the host and services to nagios server from the command line.

Now login into your Nagios  Server from the command line you will need to do following steps:

  • Install NRPE Plugin
  • Add the Linux Server to the host file
  • Configure Services

Let’s start by the first step. Once the remote host has been set up, configure the Nagios monitoring server by installing the NRPE plugin. NRPE plugins only, need to be installed on the Nagios server.

Download latest NRPE Plugin with wget command.

cd /tmp

Then extract the NRPE source.

tar xzf nrpe-2.15.tar.gz
cd nrpe-2.15

Compile and install the NRPE addon.

make all
make install-daemon

Now make sure your nagios is able to connect nrpe client on remote Linux system. Try to execute following command. In this example is the ip address of the remote host.

# /usr/local/nagios/libexec/check_nrpe -H
NRPE v2.15

If you see output that is similar it is functioning correctly.

Then add host entry for each remote box you will monitor. This example is using the linux­server template, be sure to
check that template out to verify the settings are the ones you want to use.

Edit the hosts.cfg file and add the default host template name and define remote hosts as shown below

nano /usr/local/nagios/etc/hosts.cfg
define host{ 
 use linux­server
 host_name class 
 alias Base 

The last step is the configure services. Each service you want to monitor on the remote host must be entered individually.The check_nrpe command is used to access the remote server and then execute the Nagios plugin that is on the remote server and retrieve the information.

Now open services.cfg file add the following services to be monitored.

define service{
        use                     generic-service
        host_name               class 
        service_description     CPU Load
        check_command           check_nrpe!check_load

define service{
        use                     generic-service
        host_name               class
        service_description     Total Processes
        check_command           check_nrpe!check_total_procs

define service{
        use                     generic-service
        host_name               class
        service_description     Users Load
        check_command           check_nrpe!check_users

define service{
        use                     generic-service
        host_name               class
        service_description     Check Zombies
        check_command           check_nrpe!check_zombie_procs

define service{
        use                     generic-service
        host_name               class
        service_description     Check hda1
        check_command           check_nrpe!check_hda1

Next, verify Nagios Configuration files for any errors.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0

Finally, restart Nagios.

service nagios restart

Log into the web interface via : http://[SERVER_IP]/nagios , enter your login information and check for new Linux hosts added in nagios core service.


That’s all.

Congratulations! Enjoy your Monitoring platform Nagios Core.