This post explains installing nagios with nrpe to monitor remote hosts. Nagios is one of the most used monitoring tools today.
On Remote client server to be monitored:
Create the user nagios and set password:
# useradd nagios
# passwd nagios
# mkdir -p /opt/Nagios/Nagios_Plugins
# cd /opt/Nagios/Nagios_Plugins
# cd ..
# tar xzf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
Compiling and Installing:
Pere-requisite openssl-devel package.
#rpm -q openssl-devel
if not installed, then
# yum -y install openssl-devel
Configuring:
# cd /opt/Nagios/nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
If the configure struck with ICMP ping check run as below
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-ping-command=ping
# make
# make install
Changing permissions:
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec
Installing xinetd super demon if not installed
# yum install xinetd
Now downloading and installing nrpe demon from
# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
#cd ..
# tar -xzf nrpe-2.12.tar.gz
# cd nrpe-2.12
Compiling and Configuring nrpe
# cd /opt/Nagios/nrpe-2.12
# ./configure
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# make install-xinetd
Add Nagios Monitoring server to the “only_from” directive
# vi /etc/xinetd.d/nrpe
only_from =
Add entry for nrpe daemon to services
# vi /etc/services
nrpe 5666/tcp # NRPE
Restart Xinetd and set chkconfig on
# chkconfig xinetd on
# service xinetd restart
Checking whether NRPE daemon is running and listening on port 5666:
# netstat -at |grep nrpe
tcp 0 0 *:nrpe *.* LISTEN
Open Port 5666 on Firewall
if using csf add 5666 to TCP_IN and TCP_OUT in /etc/csf/csf.conf and restart as
#csf -r
And add the following lines to /usr/local/nagios/etc/nrpe.cfg
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda
command[check_mem]=/usr/local/nagios/libexec/check_mem 85 95
Nagios server Setup (mail nagios server)
Downloading and installing nrpe demon from
# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
#cd ..
# tar -xzf nrpe-2.12.tar.gz
# cd nrpe-2.12
Compiling and Configuring nrpe
# cd /opt/Nagios/nrpe-2.12
# ./configure
# make all
# make install-plugin
Check NRPE daemon is functioning from nagios server.
# /usr/local/nagios/libexec/check_nrpe -H
Output:
NRPE v2.12
Check whether it is defined or not.
# vi /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
If you want to add a few ips then define them in hosts.cfg
and make a hostgroup in hostgroups.cfg with all the needed users as members
and now in services.cfg and the services you want and specidy hostgroup name as follows
### CPU LOAD/Load Average ###
define service{
use basic-service
hostgroup_name customer1
contact_groups admins
service_description CPU LOAD
check_command check_nrpe!check_load
}
### Disk Usage ###
define service{
use basic-service
hostgroup_name customer1
contact_groups admins
service_description CHECK DISK
check_command check_nrpe!check_disk
}
### RAM Usage ###
define service{
use basic-service
hostgroup_name customer1
contact_groups admins
service_description CHECK MEM
check_command check_nrpe!check_mem
Check the configuration as :
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Now restart
#/etc/init.d/nagios restart