对远程Linux 主机是否存活做了监控,而判断远程机器是否存活,我们可以使用ping 工具对其监测
还有一些远程主机服务,例如ftp、ssh、http,都是对外开放的服务,即使不用Nagios,我们也可以试的出来,随便找一台机器看能不能访问这些服务就行了
但是对于像磁盘容量,cpu负载这样的"本地信息",Nagios只能监测自己所在的主机,而对其他的机器则显得有点无能为力
nagios有这样一个附加组件--"NRPE",用它就可以完成对Linux 类型主机"本地信息"的监控

NRPE 总共由两部分组成:
check_nrpe 插件,位于监控主机上
NRPE daemon,运行在远程的Linux主机上(通常就是被监控机)
按照上图,整个的监控过程如下:
当Nagios 需要监控某个远程Linux 主机的服务或者资源情况时:
Nagios 会运行check_nrpe 这个插件,告诉它要检查什么;
check_nrpe 插件会连接到远程的NRPE daemon,所用的方式是SSL;
NRPE daemon 会运行相应的Nagios 插件来执行检查;
NRPE daemon 将检查的结果返回给check_nrpe 插件,插件将其递交给nagios做处理。
注意:NRPE daemon 需要Nagios 插件安装在远程的Linux主机上,否则,daemon不能做任何的监控
在被监控机(Nagios-Linux)上
增加用户&设定密码
useradd nagios
passwd nagios
安装Nagios 插件
tar zxvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --prefix=/usr/local/nagios
make && make install
这一步完成后会在/usr/local/nagios/下生成三个目录include、libexec和share。
修改目录权限
chown -R nagios.nagios /usr/local/nagios
安装nrpe
http://sourceforge.net/projects/nagios/files/
wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
#如果要支持带参数,则需要加上
./configure --enable-command-args
make all
#安装check_nrpe 这个插件
make install-plugin
#监控机需要安装check_nrpe 这个插件,被监控机并不需要,我们在这里安装它只是为了测试目的。
#安装deamon
make install-daemon
#安装配置文件
make install-daemon-config
编辑/etc/services 文件,增加NRPE服务
nrpe 5666/tcp #nrpe
#启动nrpe 服务
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
将NRPE运行添加加入系统启动脚本中
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.d/rc.local
#测试NRPE是否则正常工作
#在监控机上执行check_nrpe ,测试被监控机的nrpe 是否正常
./check_nrpe -H 192.168.146.170
#nrpe 命令
check_nrpe --H 被监控的主机 -c 要执行的监控命令
如:
./check_nrpe -H 192.168.146.170 -c check_load
./check_nrpe -H 192.168.146.170 -c check_users
在监控主机(Nagios-Server)
安装check_nrpe 插件;
在commands.cfg 中创建check_nrpe 的命令定义,因为只有在commands.cfg 中定义过的命令才能在services.cfg 中使用;
创建对被监控主机的监控项目;
安装check_nrpe 插件
tar zxvf nrpe-2.15.tar.gz # cd nrpe-2.15 # ./configure --enable-command-args # make all # make install-plugin
只运行这一步就行了,因为只需要check_nrpe插件。
在Nagios-Linux 上我们已经装好了nrpe,现在我们测试一下监控机使用check_nrpe 与被监控机运行的nrpe daemon之间的通信。