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 !


  • taivna

    hi sir I have problem in nrpe. make is not working. pls see my command result

    checking for SSL headers… configure: error: Cannot find ssl headers
    root@enkhtaivan-desktop:/home/nagios/nrpe-2.12# sudo make all
    make: *** No rule to make target `all’. Stop.

  • taivna

    root@enkhtaivan-desktop:/home/nagios/nrpe-2.12# sudo make
    make: *** No targets specified and no makefile found. Stop.

  • vmb


    you have to install openssl to resolve this problem


  • pirat9

    maybe your have to ./configure first , before make command

  • synoptik

    you need to install openssl devel
    # yum install openssl-devel

  • jiji

    to fix the problem of ssl headers write:
    apt-get install libssl-dev
    make all
    good luck

  • jiji

    [quote=jiji]to fix the problem of ssl headers write:
    apt-get install libssl-dev
    make all
    good luck[/quote]
    oh sorry i didn’t seen th date; :oops: so late sorry

  • jiji

    1/plz this commande netstat -at | grep nrpe didn’t give any out put is that mean that there is something wrong in my work?

    2/plz i tried to run this commande :
    /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
    but i got as output:Connection refused by host

    what s that mean???heelp plz :cry:

  • jiji

    hi until netstat -at | grep nrpe every thig its ok;but after that when i run this command /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users it gives me as output:
    CHECK_NRPE: Error – Could not complete SSL handshake.

    i don’t know what to do :cry:

  • jiji

    hi plz how can i get the ip adress of my nagios server

  • baron

    login to your nagios server and command ifconfig

    its easy man!!!!!!!!!

  • jiji

    hi im trying to ad my linux machine to nagios server but when i receive many errors (i followed the tuto exactly ):
    1/ chown nagios.nagios /usr/local/nagios

    i got as output:/usr/bin/install: invalid user `nagios’

    2/ make install-plugin
    =>cd ./src/ && make install-plugin
    make[1]: Entering directory `/home/jeny/nrpe-2.12/src’
    /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
    /usr/bin/install: invalid user `nagios’
    make[1]: *** [install-plugin] Error 1
    make[1]: Leaving directory `/home/jeny/nrpe-2.12/src’
    make: *** [install-plugin] Error 2

    please help :cry:

  • pirat9

    open your eyes man .
    invalid user `nagios’

  • jiji

    yes i see invalid user but i used as user:nagios pw:nagios like the first line in the tuto ,i didn’t use another user,

  • nina

    im in the last stade of adding linux host to nagios server but i can’t go on because of this commande:
    Cp linux-server.cfg linux-remotemachine.cfg
    cause i don’t have those configuration files :linux-server.cfg and linux-remotemachine.cfg

    i need your help guys :roll: thanx

  • jovin


    I’m getting an error when running this test command:

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

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

    I would get:
    CEHCK_NRPE: Error – Could not complete SSL handshake.

    What was your fix in resolving this issue?


  • nina

    In this case, you need to check on the /etc/xinetd.d/nrpe as following.

    # default: on
    # description: NRPE (Nagios Remote Plugin Executor)
    service nrpe
    flags = REUSE
    socket_type = stream
    port = 5666
    wait = no
    user = nagios
    group = nagios
    server = /usr/local/nagios/bin/nrpe
    server_args = -c /usr/local/nagios/etc/nrpe.cfg –inetd
    log_on_failure += USERID
    disable = no
    only_from =

    You need to make sure the only_from ip is the IP for nagios monitoring

    If the only_from IP is not correct, rectify it and then restart xinetd.d
    by using the following command.

    [admin@remotehost ~]$ sudo /etc/init.d/xinetd restart
    Stopping xinetd: [ OK ]
    Starting xinetd: [ OK ]

  • nina

    go to the host were u installed nqgios and type ifconfig copy the ip adress and put it in only_form ok??

  • jovin

    The nrpe file has the IP of the nagios server on the "only_from". And, have tried the stop, start, and restart the xinetd service – I’ve also tried rebooting the server for out of desperation. Still no go.

    I checked the logs it this is what it gave me.
    Nov 4 13:35:28 centos-naggy xinetd[5626]: libwrap refused connection to nrpe (libwrap=nrpe) from Nagios_IP
    Nov 4 13:35:28 centos-naggy xinetd[5626]: FAIL: nrpe libwrap from=Nagios_IP
    Nov 4 13:35:28 centos-naggy xinetd[5613]: START: nrpe pid=5626 from=Nagios_IP
    Nov 4 13:35:28 centos-naggy xinetd[5613]: EXIT: nrpe status=0 pid=5626 duration=0(sec)

    Help is greatly appreciated!

  • youmari

    hi ,
    please i want to install nagios on ubuntu but i don’t know witch better ubuntu server or ubuntu desktop and witch release of ubuntu is better to use .plz can you help me :oops:

  • James

    If you want a nagios server . you have to install it on ubuntu Server

  • wsdn

    arwala awa waz3akaya….

  • niks

    good one

  • http://enteryoursiteURL... addnagtosrv1

    good tutorial! followed all steps and everything works fine up to the point of adding the remote host to the nagios server. after adding "cfg_file=/usr/local/nagios/etc/objects/remote-machine.cfg" to the nagios.cfg file, i get the following error upon restarting the nagios service: Running configuration check… CONFIG ERROR! Restart aborted. Check your Nagios configuration.
    Please advise. thanks!

  • addnagtosrv1

    figured this one out… i realized that in the remote host .cfg file there is the "HOST GROUP" section… without having previously defined any host groups, nagios would fail. i commented out the lines for the HOST GROUP and restarted nagios just fine. on to trying to get the host groups defined now! thx.

  • nishant

    how to add hostgroup in nagios

  • ashish

    while adding in client system the make all command is not working it is showing
    make: *** No rule to make target `all’. Stop., please tell what is the problem.