stands for Nagios Remote Plugin Executor. NRPE allows you to remotely execute Nagios plugins on other Linux/Unix & windows machines. This allows you to monitor remote machine metrics (disk usage, CPU load, webserver usage, database server usage, etc…,).
Nagios Plugins monitor hosts, devices, services, protocols, and applications with Nagios and give the report to NRPE. NRPE send those reports to Nagios server based on Nagios server request. So, Nagios & NRPE can perform all the process only with Nagios-plugins.
These are Required packages to install nagios:
#yum install nagios
#yum install nagios-plugins-all
#yum install nagios–common
#yum install nagios-nrpe
#yum install nagios-plugins
#yum install nagios-devel
#yum install openssl-devel
#yum install nagios-nsca
#yum install nagios-plugins-nrpe
#yum install nagios-nsca-client
Check above packages that they are available on nagios server.
We need to add nrpe service under /etc/services with exact port number and protocol:
# vi /etc/services
nrpe 5666/tcp #nrpe
Edit nrpe configuration file and add entry of nagios server ip:
# vim /etc/nagios/nrpe.cfg
## the nagios monitoring server is permitted ##
## NOTE: There is no space after the comma ##
allowed_hosts=127.0.0.1,192.168.0.160
#service nrpe restart
Check whether the service is listening or not.
# netstat –ntulp | grep nrpe
Now, add user “nagios” on server if not available.
# useradd nagios
# passwd nagios
Nagios configuration: Open cgi.cfg file and replace default nagiosadmin user to nagios user.
# vi /etc/nagios/cgi.cfg
use_authentication=1
authorized_for_system_information=nagios
authorized_for_configuration_information=nagios
authorized_for_system_commands=nagios
authorized_for_all_services=nagios
authorized_for_all_hosts=nagios
authorized_for_all_service_commands=nagios
authorized_for_all_host_commands=nagios
: wq!
Nagios password file: Add user nagios to the htpasswd.users file as follow:
# cd /etc/nagios
# htpasswd –c htpasswd.users nagios
# htpasswd htpasswd.users nagios
Now, copy “localhost.cfg” template as “server.cfg” for monitoring nagios server:
# cd /etc/nagios/objects/
# cp localhost.cfg server.cfg
Open server.cfg file and make entry for hostname, alias and ip of linux pc.This to be done for host, hostgroup and services.
# vim server.cfg
define host{
use linux-server
host_name server
alias server
address 192.168.0.160
}
define hostgroup{
hostgroup_name linux
alias Servers
members server
}
define service{
use local-service
host_name server
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
(NOTE:change hostname as “server” for rest of services as well)
Verify configuration nagios configuration file for errors:
# nagios –v /etc/nagios/nagios.cfg
If there is no DNS configured then open httpd.conf file and make entry of server as:
# vim /etc/httpd/conf/httpd.conf
ServerName 192.168.0.160:80
: wq!
Open /etc/httpd/conf.d/nagios.conf file and check the “AuthUserFile” location for nagios access:
# vim /etc/httpd/conf.d/nagios.conf
AuthUserFile /etc/nagios/htpasswd.users
Start the following services:
# service httpd start
# chkconfig httpd on
# service nagios start
# chkconfig nagios on
# service nrpe start
# chkconfig nrpe on
Run below command to check whether the nrpe service is working and its listening or not:
#/usr/lib/nagios/pulgins/check_nrpe –H 192.168.0.160
Check the nagios console from web as with user nagios:
http://192.168.0.160/nagios
Check nagios log under:
# tail –f /var/log/nagios/nagios.log
Add Linux machine to nagios server for monitoring:(192.168.0.163)
Install the following packages on client machine:
#yum install nagios-plugins-nrpe
#yum install nagios-nrpe
#yum install openssl-devel
Edit nrpe configuration file and add entry of nagios server ip:
# vim /etc/nagios/nrpe.cfg
## the nagios monitoring server is permitted ##
## NOTE: There is no space after the comma ##
allowed_hosts=127.0.0.1,192.168.0.160
We need t0 add nrpe service under /etc/services with exact port number and protocol:
# vi /etc/services
nrpe 5666/tcp #nrpe
#service nrpe restart
Check whether the service is listening or not.
# netstat –ntulp | grep nrpe
Now, come to nagios server (192.168.0.160) machine:
# cd /etc/nagios/objects/
# cp localhost.cfg linux.cfg
Open linux.cfg file and make entry for hostname, alias and ip of linux pc.This to be done for host, hostgroup and services.
# vim linux.cfg
define host{
use linux-server
host_name labclient1
alias labclient1
address 192.168.0.163
}
define hostgroup{
hostgroup_name labclient
alias Linux Servers
members labclient1
}
define service{
use local-service
host_name labclient1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
(NOTE:change hostname as “labclient1” for rest of services as well)
Now, edit ngios.cfg file and add entry for linux pc.
# vi /etc/nagios/nagios.cfg
cfg_file=/etc/nagios/objects/linux.cfg
:wq!
Verify configuration nagios configuration file for errors:
# nagios –v /etc/nagios/nagios.cfg
Run below command to check whether the nrpe service is working and its listening to client linux pc or not:
#/usr/lib/nagios/pulgins/check_nrpe –H 192.168.0.163
Start the following services on nagios server:
# service httpd start
# service nagios start
# service nrpe start
Now, check the newly added linux pc on nagios monitoring tool.
Add Window machine to nagios server for monitoring:
Install NSClient++ package on windows machine. Chose form 32bit or 64bit package.
http://nsclient.org/nscp/downloads
Once downloaded the package run the exe file and enter the allow host ip i.e. nagios server ip (192.168.0.150), NSClient password as “password “and also load the following modules as well:
Enable common check plugins
Enable NSClient server (check_nt)
Enable nrpe server (check_nrpe)
Enable WMI checks
Now start the NSClient++ service by:
Control Panel > Administrative Tools > services > NSClient++ > stop > start
If you want to do changes for NSClient then can edit “nsclient.ini” file to modify the settings whether its for ip address or for password etc.
C:\Program Files\NSClient++\nsclient.ini
After make changes don’t forget to restart the NSClient service.
Now come to the nagios server and do the followings:
Come to nagios server (192.168.0.160) machine:
# cd /etc/nagios/objects/
# vim windows.cfg
Open windows.cfg file and make entry for hostname, alias and ip of window pc.This to be done for host, hostgroup and services.
define host{
use windows-server ; Inherit default values from a template
host_name admin1
alias My Windows Server
address 192.168.0.100 ; IP address of the host
}
Now, check ngios.cfg file and make sure there should be entry for windows pc.
# vi /etc/nagios/nagios.cfg
cfg_file=/etc/nagios/objects/windows.cfg
: wq!
Verify configuration nagios configuration file for errors:
# nagios –v /etc/nagios/nagios.cfg
Run below command to check whether the nrpe service is working and its listening to client windows pc or not:
#/usr/lib/nagios/pulgins/check_nrpe –H 192.168.0.100
Start the following services on nagios server:
# service httpd start
# service nagios start
# service nrpe start
Now, check the newly added windows pc on nagios monitoring tool.