Skip to content

NRPE Installation and Client Configuration [ Nagios ]

Disclaimer:
This is just a custom guide to install and configure Nagios Remote Plugin Executor  on Centos 7.x, this could be more technical and advanced, if you do not understand or don’t know what you are doing, I kindly request you to take extreme caution and the components used here on GCP are billable. SKYDEVOPS/I/WE do not take any responsibility if the guide causes any serious damage or issues, which you have to take full responsibility.

Installation Guide:

  1. Installation of check_nrpe on the Nagios server
  2. Installation of NRPE on the Nagios client
  3. Installation of Plugins on the Nagios client
  4. installation od xinetd on the Nagios Client
  5. Configuration of Hosts and Services configurations on Nagios Server
  • Installation on Nagios Server
    • To Installation and configuration of Nagios Server on Centos 7.x, use the following link [ Nagios Server Installation Guide ]
    • Installation and configuration of check_nrpe:
  • Installation on Nagios Client
# Install Pre-Requesites
$ sudo yum install -y gcc glibc glibc-common openssl openssl-devel perl wget
# Download the latest NRPE
$ cd /opt
$ sudo wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
# Extract NRPE
$ sudo tar xf nrpe-3.2.1.tar.gz
# Compile and Install NRPE
$ sudo ./configure && sudo make all && sudo make install
  • Nagios Plugin Installation on the Client
$ cd /opt
$ sudo wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
$ sudo tar xf nagios-plugins-2.2.1.tar.gz
$ cd nagios-plugins-2.2.1
$ sudo ./configure && sudo make all && sudo make install
  • Installation of xinetd super deamon on the Nagios Client

$ sudo yum install xinetd -y

  • configuring xinetd server

$ sudo vi /etc/xinetd.d/nrpe

service nrpe
{
flags = REUSE
type = UNLISTED
port = 5666
socket_type = stream
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 = 10.1.0.181 135.126.11.119
}

  • Configuration files on Nagios Client

# Create necessary configuration files

$ sudo mkdir -p /usr/local/nagios/etc
$ sudo cp /opt/nrpe-3.2.1/sample-config/nrpe.cfg /usr/local/nagios/etc
$ sudo touch /usr/local/nagios/etc/hosts.cfg
$ sudo touch /usr/local/nagios/etc/services.cfg

  • Added Hosts and Service config to main Nagios configuration

# Edit the main Nagios Server config to add hosts and services confs

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

cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg

  • Defining client configuration on the Server

# defining hosts
define host {
use linux-server
host_name ngwebsrv
alias SKY Nginx web server
address 135.226.152.213
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}

  • Defining check_nrpe command

# Defining check_nrpe command
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

  • Defining services for the client

# CPU Load example
define service{
use generic-service
host_name ngwebsrv
service_description CPU Load
check_command check_nrpe!check_load
}

# USER Check example
define service{
use generic-service
host_name ngwebsrv
service_description Current Users
check_command check_nrpe!check_users
}

# Total Process
define service{
use generic-service
host_name ngwebsrv
service_description Total Processes
check_command check_nrpe!check_total_procs
}

  • Restart the Nagios server and you can start monitoring the clients on the server

$ sudo systemctl restart nagios

Shashi View All

A passionate devops and automation engineer

Leave a comment