Add Linux host to nagios server

nagiosNagios is the industry standard in enterprise-class monitoring for good reason. It allows you to gain insight into your network and fix problems before customers know they even exist. It’s stable, scalable, supported, and extensible. We did show you before how to install Nagios in this Tutorial

So today will be how to add Linux client to the Nagios server .

To start , In the remote host add nagios user :

/usr/sbin/useradd nagios passwd nagios

We need two packages .

Nagios-plugin and Nrpe (download the latst version from the nagios web site)

Compile and install the plugins. (1.4.13)

make install

The permissions on the plugin directory and the plugins will need to be fixed at this point, so run the following commands.

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

Install XINETD .


yum Install xinetd

In other Linux distro please use : apt-get (UBUNTU/DEBIAN) or zypper (OPENSUSE) or your slackware download manager .

Install the NRPE daemon

Download the source code tarball of the NRPE addon (visit for links to the latest

versions). At the time of writing, the latest version of NRPE was 2.12.

cd ~/downloads

Extract the NRPE source code tarball.

tar xzf nrpe-2.12.tar.gz
cd nrpe-2.12

Compile the NRPE addon.


Install the NRPE plugin (for testing), daemon, and sample daemon config file.

make install-plugin
make install-daemon
make install-daemon-config

Install the NRPE daemon as a service under xinetd.

make install-xinetd

Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.

only_from =

Add the following entry for the NRPE daemon to the /etc/services file.

nrpe 5666/tcp # NRPE

Restart the xinetd service.

service xinetd restart

Test the NRPE daemon locally

Its time to see if things are working properly…

Make sure the nrpe daemon is running under xinetd.

netstat -at | grep nrpe

The output out this command should show something like this:

tcp 0 0 *:nrpe *:* LISTEN

if you are using the IPtables please add this line :

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 5666 -j ACCEPT

Save the new iptables rule so it will survive machine reboots.

service iptables save

NRPE commands

You can test some of these

by running the following commands:

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_users

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs

Now back to your Nagios Server , and Install NRPE deamon :

Download nrpe and extract.

make all

Install the NRPE plugin

make install-plugin

check of nrpe is working we will check the nrpe in the remote host :

[root@Nagios-Server nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H

NRPE v2.12

Now in the nagios server :

Go to

Cd /usr/local/nagios/etc/objects
Cp linux-server.cfg linux-remotemachine.cfg

Open linux-remotemachine.cfg and edit the hostname and IP adress

Save exit

Cd /usr/local/nagios/etc
Vi nagios.cfg

Add this line :

# Definitions for monitoring the local (Linux) host




save and exit

fine :

now check if you nagios server nagios can start without errors

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios 3.1.0

Copyright (c) 1999-2009 Ethan Galstad (

Last Modified: 01-25-2009

License: GPL

Reading configuration data…

Read main config file okay…

Processing object config file ‘/usr/local/nagios/etc/objects/commands.cfg’…

Processing object config file ‘/usr/local/nagios/etc/objects/contacts.cfg’…

Processing object config file ‘/usr/local/nagios/etc/objects/timeperiods.cfg’…

Processing object config file ‘/usr/local/nagios/etc/objects/templates.cfg’…

Processing object config file ‘/usr/local/nagios/etc/objects/Nagios-server.cfg’…

Processing object config file ‘/usr/local/nagios/etc/objects/Tornado01.cfg’…

Processing object config file ‘/usr/local/nagios/etc/objects/Tornado02.cfg’…

Read object config files okay…

Running pre-flight check on configuration data…

Checking services…

Checked 25 services.

Checking hosts…

Checked 3 hosts.

Checking host groups…

Checked 3 host groups.

Checking service groups…

Checked 0 service groups.

Checking contacts…

Checked 1 contacts.

Checking contact groups…

Checked 1 contact groups.

Checking service escalations…

Checked 0 service escalations.

Checking service dependencies…

Checked 0 service dependencies.

Checking host escalations…

Checked 0 host escalations.

Checking host dependencies…

Checked 0 host dependencies.

Checking commands…

Checked 24 commands.

Checking time periods…

Checked 5 time periods.

Checking for circular paths between hosts…

Checking for circular host and service dependencies…

Checking global event handlers…

Checking obsessive compulsive processor commands…

Checking misc settings…

Total Warnings: 0

Total Errors: 0

Things look okay – No serious problems were detected during the pre-flight check

Now restart nagios with

[root@Nagios-Server etc]# service nagios restart

Running configuration check…done.

Stopping nagios: done.

Starting nagios: done.

Open your nagios page and see is done !


Please shareShare on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Digg thisShare on StumbleUpon0Share on VKBuffer this page