Introduction
NRPE stand for Nagios Remote Plugin Executor, Which nagios’s agent and allow to monitoring nagios’s client machine services and applications like Apache, mysql, redis, solr, Jenkins etc.
Requirement
- Root permission access.
- Basic knowledge of linux commands.
In this blog we are going to configure nagios remote machine using NRPE plugin uisng ubuntu 16.04 and we must have running nagios server in a same network.
Nagios client side installation and configuration:-
Step 1: Installation of Nagios Plugins
You need login as root user in your nagios’s client machine and need to install required packages by following the commands.
sudo -i
apt update
apt install nagios-nrpe-server nagios-plugins -y
Step 2: Nagios server ip configuration on NRPE Agent
To allow nagios server to access the remote machine you need to edit the /etc/nagios/nrpe.cfg file by using given commands.
nano /etc/nagios/nrpe.cfg
Add the Nagios servers IP address, separated by comma like below.
allowed_hosts=192.168.1.10
Save and exit from the nano editor.
Step 3: Verifying Nagios Checks
To get status of machine CPU, Memory, Disk Spcace, Totoal Process, and more, We need to verify the all pre configure nagios check is working file for that we need to opwn the nrpe.cfg config file using following commands and check the nrpe commands.
to check monitoring check you need to move /usr/lib/nagios/plugins/
and test some nrpe commands by following the command.
./check_procs -w 200 -c 250
here w for warning and c for critical status for nagios alerts and after execute the commands you will get output of the checks like that.
PROCS OK: 190 processes | procs=189;200;250;0;
After that you need to restart the nrpe service and enable nrpe service on boot.
systemctl restart nagios-nrpe-server
systemctl enable nagios-nrpe-server
ufw allow 5666/tcp
Your client side nagios host configuration is completed.
Step 4: Server-side nagios configuration for remote machine
Login to your nagios-server with root privileges and edit the nagios main config file located in /usr/local/nagios/etc/nagios.cfg
and add the nagios-client server directory or uncomment it.
nano /usr/local/nagios/etc/nagios.cfg
and uncommet the following lines.
cfg_dir=/usr/local/nagios/etc/servers
You need to create a configuration directory.
mkdir /usr/local/nagios/etc/servers
Step 5: Configure Nagios Server
Now it’s time to configure the Nagios server to monitor the remote client machine, and You’ll need to create a command definition in Nagios object configuration file to use the check_nrpe
plugin. Open the commands.cfg file.
nano /usr/local/nagios/etc/objects/commands.cfg
Paste the follwoing configuration.
# .check_nrpe. command definition
define command{
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}
Save and exit.
Step 6: Configure remote nagios client
Open the configuration file.
nano /usr/local/nagios/etc/servers/client.cfg
Paste the following configurtion.
define host{
use linux-server
host_name client
alias client
address 10.10.10.11
}
define hostgroup{
hostgroup_name linux-server
alias Linux Servers
members client
}
define service{
use local-service
host_name client
service_description SWAP Uasge
check_command check_nrpe!check_swap
}
define service{
use local-service
host_name client
service_description Root / Partition
check_command check_nrpe!check_root
}
define service{
use local-service
host_name client
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use local-service
host_name client
service_description Total Processes
check_command check_nrpe!check_total_procs
}
define service{
use local-service
host_name client
service_description Current Load
check_command check_nrpe!check_load
}
Save and exit from nano editor.
Step 6: Verify Nagios for any errors
Execute the follwing command check error with nagios.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Step 7: Restart the Nagios server
To get new changes we need to restart the nagios server by using the following command.
systemctl restart nagios
Now open the browser with http://localhost/nagios and you should get this screen.
Now nagios nrpe client is successful configured.
Useful information, Publish more tutorials on Ubuntu server thanks you
Yo.
Awesome work.
Awesome.