上一节我们在FreeBSD上实现了了安装nagios(http://blog.haohtml.com/archives/4579),下面我们要监控一台linux(centos)的主机.
Note: It is possible to execute Nagios plugins on remote Linux/Unix machines through SSH. There is a
check_by_ssh plugin that allows you to do this. Using SSH is more secure than the NRPE addon, but it also imposes a larger (CPU) overhead on both the monitoring and remote machines. This can become an issue when you start monitoring hundreds or thousands of machines. Many Nagios admins opt for using using the NRPE addon because of the lower load it imposes.
一、实现原理
The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor “local” resources (like CPU load, memory usage, etc.) on remote machines. Since these public resources are not usually exposed to external machines, an agent like NRPE must be installed on the remote Linux/Unix machines.
b、通过 SSL,check_nrpe 连接被监控主机的 NRPE daemon
c、NRPE 运行本地的各种插件去检测本地和远端的服务和状态(check_disk,..etc)
d、最后,NRPE 把检测的结果传给主机端的 check_nrpe,check_nrpe 再把结果送到 Nagios状态队列中。
e、Nagios 依次读取队列中的信息,再把结果显示出来。
二、被监控主机安装Nrpe
1、create account information
[root@ypd ~]# adduser nagios
wget http://mcshell.org/nagios-plugins-1.4.13.tar.gz
./configure
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
allowed_hosts=127.0.0.1,IP
/usr/local/nagios/bin/nrpe -c ../etc/nrpe.cfg -d查看端口是否启用监听netstat -an | grep 5666