How to add client in Nagios Monitoring Server by using NRPE Plugin

Adding Linux Host to Nagios Monitoring Server Using NRPE Plugin

The NRPE (Nagios Remote Plugin Executor) plugin allows you to monitor any remote Linux services. This add-on allows Nagios to monitor resources like CPU load, Swap, Memory usage, Online users, etc., Procedures to add linux host to Nagios Monitoring Server using NRPE plugin is explained in this article.

Features

  • Monitor your entire IT infrastructure.
  • Identify problems before they occur.
  • Know immediately when problems arise.
  • Share availability data with stakeholders.hypothetical question.
  • Detect security breaches.
  • Plan and budget for IT upgrades.
  • Reduce downtime and business losses.

server

client side

To install epel repository

[root@linuxhelp1 ~]# yum install epel-release -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package epel-release.noarch 0:7-6 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
  epel-release.noarch 0:7-6                                                                                                       

Complete!

To Install the nrpe and nrpe plugins in client system

[root@linuxhelp1 ~]# yum install nrpe nagios-plugins-all openssl -y 
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink                                                                                       | 5.2 kB  00:00:00    
epel                                                                                                       | 4.3 kB  00:00:00    
(1/3): epel/x86_64/updateinfo                                                                              | 576 kB  00:00:06    
(2/3): epel/x86_64/primary_db                                                                              | 4.2 MB  00:00:11    
(3/3): epel/x86_64/group_gz                                                                                | 170 kB  00:00:15    
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: epel.mirror.net.in
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
-->  Running transaction check
--->  Package nagios-plugins-all.x86_64 0:2.0.3-3.el7 will be installed
-->  Processing Dependency: nagios-plugins-wave for package: nagios-plugins-all-2.0.3-3.el7.x86_64
.
.
.
nagios-plugins-swap.x86_64 0:2.0.3-3.el7                         nagios-plugins-tcp.x86_64 0:2.0.3-3.el7                       
nagios-plugins-time.x86_64 0:2.0.3-3.el7                         nagios-plugins-ups.x86_64 0:2.0.3-3.el7                       
nagios-plugins-users.x86_64 0:2.0.3-3.el7                        nagios-plugins-wave.x86_64 0:2.0.3-3.el7                      
net-snmp-utils.x86_64 1:5.7.2-24.el7_2.1                         postgresql-libs.x86_64 0:9.2.15-1.el7_2                       
qstat.x86_64 0:2.11-13.20080912svn311.el7                       

Updated:
  openssl.x86_64 1:1.0.1e-51.el7_2.5                                                                                              

Dependency Updated:
  net-snmp-libs.x86_64 1:5.7.2-24.el7_2.1                         openssl-libs.x86_64 1:1.0.1e-51.el7_2.5                        

Complete!

Configure the monitoring target

[root@linuxhelp1 ~]# vim /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.5.231

Start the nrpe service in the client

[root@linuxhelp1 ~]# systemctl start nrpe
[root@linuxhelp1 ~]# chkconfig nrpe on
Note: Forwarding request to ' systemctl enable nrpe.service' .
ln -s ' /usr/lib/systemd/system/nrpe.service'  ' /etc/systemd/system/multi-user.target.wants/nrpe.service' 

On server side

Open the nagios.cfg file located on /usr/local/nagios/etc/

[root@linuxhelp ~]# vim /usr/local/nagios/etc/nagios.cfg

Uncomment the following line.

cfg_dir=/usr/local/nagios/etc/servers

Create a directory in the name of server under the directory “ /usr/local/nagios/etc/

[root@linuxhelp ~]# mkdir /usr/local/nagios/etc/servers

Configure the client to be monitored.

[root@linuxhelp ~]# vim /usr/local/nagios/etc/servers/clients.cfg
define host{
use linux-server
host_name node1
alias node1
address 192.168.7.232
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}

Restart the nagios service.

[root@linuxhelp ~]# systemctl restart nagios

Open the nagios in web browser and click Hosts menu to view the newly created host. Then select node1.

Host node1 information appears as follows.

For defining the service

Add the following code in the client configuration file located in /usr/local/nagios/etc/servers/

define service
{
use generic-service
host_name node1
service_description SSH
check_command check_ssh
notifications_enabled 0
}

Restart the nagios service

[root@linuxhelp ~]# systemctl restart nagios

Open the nagios in browser and click services. To check whether the SSH services added or not.

FAQ
Q
What is NRPE (Nagios Remote Plugin Executor) in Nagios?
A
The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor “local” resources (like CPU load,
Q
How do I compile the plugins?
A
To compile version 1.x of the plugins, you run:

$ gzip -dc nagios-plugins-1.x.tar.gz | tar -xf -
$ cd nagios-plugins-1.x
$ ./configure
$ make
Q
How to install nagios-nrpe server on ubuntu?
A
For the installation of Nagios-server on Ubuntu, run the following command on the termainl "apt-get install nagios-nrpe-server "
Q
Why aren't the root plugins installed?
A
There are a few plugins which require root access, namely check_dhcp and check_icmp. These are compiled under the plugins-root subdirectory. A make install will install them with the install user's owner and group permissions. However, if you run make install without being root, this message will appear:

WARNING: insufficient access; not installing setuid plugins
NOTE: to install setuid plugins, run 'make install-root' as root

To install, run as root:

$ make install-root

Even if you are not root, the plugins will still be installed. This is for packagers which can then alter the permissions of the plugins before packaging.

This behaviour is used by coreutils for the su binary and is duplicated for this project.
Q
Which user owns the installed plugins?
A
If you run ./configure --with-user=nagios, then at make install time, the installation will set the ownership of the plugins to the nagios user (similarly for --with-group). If these options are not set, the plugins will be installed with the install user's owner and group permissions - it is your responsibility to set other permissions, if required.

The only exception are root plugins. These are under plugins-root/ and are also installed with the install user's owner and group permissions.

If you run:

$ make install-root

This will set permissions to root, assuming you are either root or using fakeroot. If not, the setuid bit is still set, but the plugin may not work correctly. This is the behaviour used by coreutils for the su binary and is duplicated in this project.