Nagios 4.1.1: Adding Linux host to Nagios Monitoring server


Installing Dependencies

# yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd ntp openssl* nagios-nrpe*

Create a new nagios user account and set a password. 

# useradd nagios
# passwd Nagios

Nagios Plugins installation:

We needed to install Nagios plugins in to the client so that it can execute the commands given by nagios server 
# mkdir /root/nagios
cd /root/nagios
# wget https://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
# tar -xvf nagios-plugins-2.1.1.tar.gz
cd nagios-plugins-2.1.1.tar.gz
# ./configure
# make
# make install
# service openssl restart

# service nrpe start

Add the permission to the nagios user for /usr/local/nagios folders where the nagios plugins are installed just now 
# chown  nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec

Installing NRPE client on Linux host:
NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. 

This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons, so you can execute scripts and check metrics on remote Windows machines as well.

Same steps as above. First create the folder:

# mkdir -p /usr/local/src/nrpe
# cd /usr/local/src/nrpe

Download the files and extract:
# wget http://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
# tar -xf nrpe-2.15.tar.gz
# cd nrpe-2.15

Because of an issue with the openssl library folder we need to use another path than /usr/lib:

#./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

Now make and make install:
# make all

Next, install the NRPE plugin daemon, and sample daemon config file. 

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

Install the NRPE daemon under xinetd as a service.

# make install-xinetd

Next, open /etc/services file add the following entry for the NRPE daemon at the bottom of the file.

# vi /etc/services

nrpe            5666/tcp                 NRPE

Restart the xinetd service.

# service xinetd restart

Verify NRPE Daemon Locally

Run the following command to verify the NRPE daemon working correctly under xinetd.

# netstat -at | grep nrpe

tcp        0      0 *:nrpe                      *:*                         LISTEN

Next, verify the NRPE daemon is functioning properly. Run the “check_nrpe” command that was installed earlier for testing purposes.
# /usr/local/nagios/libexec/check_nrpe -H localhost

You will get a following string on the screen, it shows you what version of NRPE is installed:

NRPE v2.15

In order to monitor Linux client we needed to edit 2 configuration files in the Nagios server 

Login to the Nagios server 

Step 1. Edit hosts.cfg file to add the Linux client and add the client configuration

# vi /usr/local/nagios/etc/hosts.cfg

define host{
use                             linux-box               ; Inherit default values from a template
host_name                  New linux    ; The name we're giving to this server
alias                           CentOS 6                ; A longer name for the server
address                      192.168.1.84            ; IP address of Remote Linux host
}

Step 2. Edit services.cfg file to add the Linux client host_name to the services which we want to moinitor

#vi /usr/local/nagios/etc/services.cfg

define service{
        use                          generic-service
        host_name               Testbox,{ new_linux_machine_hostname_defined in hosts.cfg }
        service_description    CPU Load
        check_command       check_nrpe!check_load    
 }

Needed to add the Hostname which is given in the hosts.cfg file for the servies you want to monitor

Step 3. Finally, verify Nagios Configuration files for any errors and restart the nagios services 

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

# service nagios restart


Now go to Nagios Monitoring Web interface at “http://Your-server-IP-address/nagios” or “http://FQDN/nagios”


Nagios 4.1.1 other links:

Keywords: Nagios, Monitoring, Linux host, Ading Linux host

Comments

Popular posts from this blog

Observium: Configuring Microsoft Windows 2008 Server SNMP Agent

AWS: Introduction to AWS (Amazon Web Services)

System/Server Health Status using PowerShell