In our testing environment, we will setup Nagios to monitor host centos-1 and centos-2 using NRPE.
To use NRPE, we need to install NRPE on both monitoring host and remote hosts:
Steps to setup remote hosts for NRPE monitoring:
1. Download nagios-plugins-1.4.16.tar.gz, nrpe-2.14.tar.gz
2. Create account for NRPE service
# useradd nagios
# passwd nagios
3. Install nagios-plugs
# tar zxpf nagios-plugins-1.4.16.tar.gz
# cd nagios-plugins-1.4.16
# ./configure --with-nagios-user=nagios \
--with-nagios-group=nagios
# make
# make install
# chown nagios:nagios /usr/local/nagios
4. Install NRPE
# tar zxpf nrpe-2.14.tar.gz
# cd nrpe-2.14
# ./configure
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
5. Modify /usr/local/nagios/etc/nrpe.cfg to allow host centos(192.168.100.100) to connect to NRPE
allowed_hosts=127.0.0.1,192.168.100.100
6. Start NRPE, enable autostart to NRPE
# /usr/local/nagios/bin/nrpe -c \
/usr/local/nagios/etc/nrpe.cfg -d
# echo '/usr/local/nagios/bin/nrpe -c \
/usr/local/nagios/etc/nrpe.cfg -d' >> /etc/rc.local
7. Verify NRPE is working properly
# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.14
Steps to setup monitoring host for NRPE monitoring
1. Download nrpe-2.14.tar.gz
2. Install NRPE
# tar -zxpf nrpe-2.14.tar.gz
# cd nrpe-2.14
# ./configure
# make all
# make install-plugin
3. Enable monitoring of centos-1
Update /usr/local/nagios/etc/objects/commands.cfg to enable command check_nrpe
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}
update /usr/local/nagios/etc/nagios.cfg to include this line
cfg_file=/usr/local/nagios/etc/objects/centos-1.cfg
4. Edit /usr/local/nagios/etc/objects/centos-1.cfg
define host{
use linux-server
host_name centos-1
alias centos-1
address 192.168.100.101
}
define hostgroup{
hostgroup_name centos
alias centos
members centos-1
}
define service{
use generic-service
host_name centos-1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name centos-1
service_description Server Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name centos-1
service_description /rhiso Usage
check_command check_nrpe!check_rhiso
}
5. Restart Nagios service
# service nagios restart
Steps to enable nrpe commands check_load and check_rhiso on remote host centos-1
Edit /usr/local/nagios/etc/nrpe.cfg, add these 2 lines:
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_rhiso]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% /rhiso
restart nrpe daemon
# pkill nrpe
# /usr/local/nagios/bin/nrpe -c \
/usr/local/nagios/etc/nrpe.cfg -d
Login to http://centos/nagios again, you will see now we have host centos-1 monitored, similarly we can setup the monitoring of centos-2
No comments:
Post a Comment