Monitor Remote Linux System with Nagios 3

Once installed the Nagios, you can monitor the system via web interface; by default it is limited  to  monitor the local machine where Nagios installed. If you like to monitor the remote Linux box or Windows box, you need to have Nagios plugin and NRPE add-on  installed on the remote box. Once installed the plugin and add-on, you need to configure the Nagios server to collect the information from the remote machine and display it on the web interface.

If you have not yet installed the Nagios; visit the Install and Setup Nagios on Centos 6. Monitoring the Remote Linux system includes the 6 Steps

Nagios Remote Host:

1. Add User Account

2. Download & Install Nagios Plugin

3. Install NRPE Add-on

4. Configure NRPE Add-On

Nagios Server Host:

1. Configure Nagios Server

2. Monitor the remote machine.

Nagios Remote Host:

Add User account:

Before proceeding the installation, add the nagios user and nagcmd group.

su -l

Create a new user in the name of “nagios” and give it a password.

useradd nagios

Set the password.

passwd nagios

 

Download & Install Nagios Plugin:

Download the Nagios and the Nagios plugins on the remote host using the following command ( For latest version Visit Nagios WebSite )

wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

Extract the Nagios plugins source code tarball.

tar -zxvf nagios-plugins-1.4.16.tar.gzcd nagios-plugins-1.4.16

Compile and install the plugins. While compiling i got an error; here is the Nagios troubleshooting Tutorial.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Change the permission of the nagios plugin directory on the remote host.

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

 

Download and install NRPE Add-on:

Visit the Nagios download page and download the NRPE Add-on.

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz

Once downloaded, Extract the tar ball.

tar -zxvf nrpe-2.13.tar.gz
cd nrpe-2.13

Compile it.

./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

Configure NRPE Add-on:

NRPE is the part of the xinetd daemon, modify the NRPE configurations file to accept the connection from the Nagios server, Edit the /etc/xinetd.d/nrpe.

vi /etc/xinetd.d/nrpe

Add the Nagios server ip address like below.

only_from = 127.0.0.1 192.168.0.151

Add NRPE port at the end of the /etc/services file.

nrpe 5666/tcp # NRPE

Restart the Xinetd.d service.

/etc/init.d/xinetd restart

Confirm that NRPE Listening.

netstat -at | grep nrpetcp 0 0 *:nrpe *:* LISTEN

Confirm the NRPE functioning.

/usr/local/nagios/libexec/check_nrpe -H localhostNRPE v2.13

 

Modify NRPE Config file:

Modify the /usr/local/nagios/etc/nrpe.cfg on the remote host, it contains the command argument to check the service on the remote host. The nrpe.cfg file contains the basic commands to check the remote services, below are the command lines to check the cpu load and running process. The check_load and check_total_procs has to be entered on template file on the server host to enable the monitoring.

command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

In the above command -w stands for warning whereas -c stands for critical alert. For example if you execute  the second command on the terminal, it will check the running process; it will warn when the process more than 150 or it will report critical when the process more than 200 and at the same time it will say OK if process below 150.

 /usr/local/nagios/libexec/check_procs -w 150 -c 200PROCS OK: 112 processes
Change warning to 100 and critical to 150 for testing purpose. Now you can see the warning message, according to your requirement you can modify it.
 /usr/local/nagios/libexec/check_procs -w 100 -c 150PROCS WARNING: 112 processes

 

Nagios Server Host:

Install NRPE Add-on:

Visit the Nagios download page and download the NRPE Add-on.

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz

Once downloaded, Extract the tar ball.

tar -zxvf nrpe-2.13.tar.gz cd nrpe-2.13

Compile it.

./configuremake allmake install-plugin

Configure Nagios Server: 

Now its the time configure the nagios server to monitor the remote client, You’ll need to create a command definition in one of your Nagios object configuration files in order to use the check_nrpe plugin. Open the sample commands.cfg file for editing…

vi /usr/local/nagios/etc/objects/commands.cfg
Add the following command definition to the file.

# .check_nrpe. command definition

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$

Create the new configuration file (/usr/local/nagios/etc/objects/remote.cfg) to define the host and service definition. You can use the following template, modify according to your requirement. The following is configured to display the Swap,CPU Load,Disk Space,Current Users. Etc..,

define host{

use                     linux-server

host_name             linuxclient1.iii.local

alias                   Client 1

address                 192.168.0.152

}

define hostgroup{

hostgroup_name  Linux Client

alias           Linux Client 1

members         linuxclient1.iii.local

}

define service{

use                             local-service

host_name                       linuxclient1.iii.local

service_description             SWAP Uasge

check_command                   check_nrpe!check_swap

}define service{

use                             local-service

host_name                       linuxclient1.iii.local

service_description             Root Partition

check_command                   check_nrpe!check_sda1

}

define service{

use                             local-service

host_name                       linuxclient1.iii.local

service_description             Current Users

check_command                   check_nrpe!check_users

}

define service{

use                             local-service

host_name                       linuxclient1.iii.local

service_description             Total Processes

check_command                   check_nrpe!check_total_procs

}

define service{

use                             local-service

host_name                       linuxclient1.iii.local

service_description             Current Load

check_command                   check_nrpe!check_load

}

Add the new template on the nagios.cfg configuration file, so that it will read the new entries.

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

Add just below.

# Definitions for monitoring the Remote (Linux) hostcfg_file=/usr/local/nagios/etc/objects/remote.cfg

Restart the Nagios server.

/etc/init.d/nagios restart


Monitor the remote machine: 

Now login to the web interface and start do the monitoring. The following screenshot shows the remote linuxbox with the default service available (which were taken from the localhost.cfg).

That’s All

Search Term:

Install Nagios,Install Nagios 3.4.4

Install Nagios on CentOS

Install Nagios on CentOS 6

Install Nagios on Redhat

Install Nagios on RHEL 6

Setup Nagios on CentOS

Configure Nagios on CentOS 6

Configire Nagios on RHEL 6

Install Nagios on Fedora

Step by Step Nagios installation

POSTS YOU MAY LIKE -:)

Share This Post

Shares