NRPE总共由两部分组成:
check_nrpe插件:运行在监控主机上 (即nagios主机)
NRPE daemon:运行在远程的linux主机上(通常就是被监控机)
当Nagios需要监控某个远程linux主机的服务或者资源情况时:
1、nagios运行check_nrpe插件,我们要在nagios配置文件中告诉它要检查什么。
2、check_nrpe插件会通过SSL连接到远程的NRPEdaemon。
3、NRPE daemon会运行相应的nagios插件来执行检查本地资源或服务。
4、NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理。
注意:NRPE daemon需要nagios插件和Nrpe一起安装在远程被监控linux主机上,否则,daemon不能做任何的监控。 别外因为它们间的通信是加密的SSL,所以需要安装SSL,这个插件需要openssl的支持,没有就直接安装一下(yuminstall openssl-devel)。 在被监控端安装nagios-plugins和nrpe 1、创建nagios用户 [iyunv@localhost /]#useradd nagios 2、编译安装nagios-plugins插件 [iyunv@localhost nagios-plugins1.4.15]#./configure --with-nagios-user=nagios --with-nagios-group=nagios [iyunv@localhost nagios-plugins1.4.15]#make && make install 3、检查xinetd是否安装,没有则安装(默认已安装)。 [iyunv@localhost /]#yum -y install xinetd 4、编译安装nrpe [iyunv@localhost nrpe-2.12]#./configure [iyunv@localhost nrpe-2.12]#make all [iyunv@localhost nrpe-2.12]#make install-plugin
[iyunv@localhost nrpe-2.12]#make install-daemon //安装守护进程 [iyunv@localhost nrpe-2.12]#make install-daemon-config //安装配置文件 [iyunv@localhost nrpe-2.12]#make install-xinetd //安装xinetd脚本 5、修改nrpe的配置文件,添加监控端的主机地址。修改内容如下:
[iyunv@localhost /]#vim /etc/xinetd.d/nrpe only_from = 127.0.0.1 192.168.10.100 //在后面增加监控主机(即nagios服务器)
6、修改/etc/services文件,增加NRPE服务,修改内容如下:
[iyunv@localhost /]#vim /etc/services //在该文件尾部添加如下行 nrpe 5666/tcp #nrpe 7、修改nrpe.cfg配置文件,修改内容如下: [iyunv@localhost /]#vim /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% 上面这5行定义的命令分别是检测登陆用户数,cpu负载,hda1的容量,僵尸进程,总进程数,SWAP分区的使用情况。
如果需要检测其他信息可自行添加其他命令。 8、开启xinetd服务,查看NRPE是否已经启动。
9、在本机测试上述配置命令是否有误,执行如下命令。 [iyunv@localhost /]#/usr/local/nagios/libexec/check_nrpe -Hlocalhost -c check_users [iyunv@localhost /]#/usr/local/nagios/libexec/check_nrpe -Hlocalhost -c check_load [iyunv@localhost /]#/usr/local/nagios/libexec/check_nrpe -Hlocalhost -c check_hda1 [iyunv@localhost /]#/usr/local/nagios/libexec/check_nrpe -Hlocalhost -c check_zombie_procs [iyunv@localhost /]#/usr/local/nagios/libexec/check_nrpe -Hlocalhost -c check_total_procs [iyunv@localhost /]#/usr/local/nagios/libexec/check_nrpe -Hlocalhost -c check_swap
此时客户端配置完成了,接着我们到nagios监控端进行配置。
在监控端安装nrpe软件包(即nagios服务器) 1、编译安装nrpe软件包
[iyunv@localhost nrpe-2.12]#./configure --with-nagios-user=nagios --with-nagios-group=nagios [iyunv@localhost nrpe-2.12]#make all [iyunv@localhost nrpe-2.12]#make all && make install-plugin
2、测试是否可以连接到被检测端。
3、在nagios的commands.cfg文件中添加nrpe命令。 [iyunv@localhost /]#vim /usr/local/nagios/etc/objects/commands.cfg
4、在nagios的hosts.cfg文件中添加被监控端主机的相关信息。 [iyunv@localhost /]#vim /usr/local/nagios/etc/objects/hosts.cfg
5、在nagios的services.cfg文件中添加需要检测的服务。
[iyunv@localhost /]#vim /usr/local/nagios/etc/objects/services.cfg
6、执行“nagios -v”命令检测配置文件语法是否正确。
[iyunv@localhost /]#/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
7、重新加载nagios服务
8、访问nagios的web界面,可以发现能够监控指定服务器的运行情况。
|