注意:两端nrpe的版本要一致,不然无法相连接
NRPE总共由两部分组成:
check_nrpe插件,运行在监控主机上。
NRPE daemon,运行在远程的linux主机上(通常就是被监控机)
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
make
make install
|
#yum install openssl-devel (安装 openssl包)
cd nagios-nrpe_2.8.1
./configure
#
默认自动添加了
openssl
#
因为传送过程要加密
,
如果后面
make
报错
,
加如下参数
rpm -qa| grep ssl
openssl-devel-0.9.7a-43.17.el4_6.1
rpm -ql openssl-devel-0.9.7a-43.17.el4_6.1 | more
./configure --enable-ssl --with-ssl-lib=/lib/
(
当然前提要有
openssl)
make all
make install-plugin
|
vi /usr/local/nagios/etc/objects/commands.cfg
#
添加
#
check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
|
vi /usr/local/nagios/etc/nagios.cfg
#
中间添加
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
|
vi /usr/local/nagios/etc/objects/mylinux.cfg
define host{
use linux-server
host_name mylinux
alias mylinux
address 192.168.1.203
(
客户端
IP
既被监控的
IP)
}
define service{
use generic-service
host_name mylinux
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name mylinux
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name mylinux
service_description check-disk
check_command check_nrpe!check_had1
}
define service{
use generic-service
host_name mylinux
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name mylinux
service_description otal_procs
check_command check_nrpe!check_total_procs
}
#这5个是默认的监控服务,如需自定义服务可在这里添加
自定义服务可参考:http://saplingidea.javaeye.com/blog/514013
如有必要则需更改check阈值,在被监控端的/usr/local/nagios/etc/nrpe.cfg,下面会提到
|
chkconfig --add nagios
#
配置机器启动时自动启动
Nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#
检查
Nagios
配置文件
vi /etc/selinux/config
#
关闭
SELinux
SELINUX=disabled
service iptables stop
#
关闭
SELinux,
或打开
80,5666
端口
service nagios start
|
useradd nagios
passwd nagios
tar -zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround
Make
make install
|
chown –R nagios.nagios /usr/local/nagios
[root@client nagios]# ll
drwxr-xr-x 2 nagios nagios 4096 Jun 1 00:07 libexec
drwxr-xr-x 3 nagios nagios 4096 Jun 1 00:07 share
|
yum install openssl-devel (安装 openssl包)
tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz
cd nagios-nrpe_2.8.1
./configure
(
会自动加载
SSL)
#
如果后面
make
报错
,
加如下参数
./configure --enable-ssl --with-ssl-lib=/usr/lib/
(
当然前提要有
openssl)
make all
make install-plugin
make install-daemon
make install-daemon-config
|
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.1.202
|
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
#上面这一步在本机上可以运行,如通过ssh连接,则需用:
/usr/local/nagios/bin/nrpe -d
vi /etc/rc.d/rc.local
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
|
netstat -an | grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.8.1
#
服务端测试
/usr/local/nagios/libexec/check_nrpe -H l92.168.1.203
NRPE v2.8.1
#
常见错误
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
CHECK_NRPE: Error - Could not complete SSL handshake.
配置
allowed_hosts=127.0.0.1,192.168.1.202
然后
kill
进程再重启就
OK
了
2./usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
Connection refused by host
Nrpe
进程没有启动
|
vi /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_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
#这里就是上面提到的check阈值,如需更改,加减后面的数值即可
|