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用户
[root@localhost /]#useradd nagios
2、编译安装 nagios-plugins插件
[root@localhost nagios-plugins1.4.15]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@localhost nagios-plugins1.4.15]#make && make install
3、检查xinetd是否安装,没有则安装(默认已安装)。
[root@localhost /]#yum -y install xinetd
4、编译安装nrpe
[root@localhost nrpe-2.12]#./configure
[root@localhost nrpe-2.12]#make all
[root@localhost nrpe-2.12]#make install-plugin
[root@localhost nrpe-2.12]#make install-daemon // 安装守护进程
[root@localhost nrpe-2.12]#make install-daemon-config // 安装配置文件
[root@localhost nrpe-2.12]# make install-xinetd // 安装 xinetd 脚本
5、修改nrpe的配置文件,添加监控端的主机地址。修改内容如下:
[root@localhost /]#vim /etc/xinetd.d/nrpe
only_from = 127.0.0.1 192.168.10.100 // 在后面增加监控主机(即 nagios 服务器)
6、修改/etc/services文件,增加NRPE服务,修改内容如下:
[root@localhost /]#vim /etc/services // 在该文件尾部 添加如下行
nrpe 5666/tcp #nrpe
7、修改nrpe.cfg配置文件,修改内容如下:
[root@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、在本机测试上述配置命令是否有误, 执行如下命令。
[root@localhost /]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
[root@localhost /]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
[root@localhost /]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1
[root@localhost /]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs
[root@localhost /]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs
[root@localhost /]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_swap
此时客户端配置完成了,接着我们到nagios监控端进行配置。
在监控端安装nrpe软件包(即nagios服务器)
1、编译安装nrpe软件包
[root@localhost nrpe-2.12]#./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@localhost nrpe-2.12]#make all
[root@localhost nrpe-2.12]#make all && make install-plugin
2、测试是否可以连接到被检测端。
3、在nagios的commands.cfg文件中添加nrpe命令。
[root@localhost /]#vim /usr/local/nagios/etc/objects/commands.cfg
4、在nagios的hosts.cfg文件中添加被监控端主机的相关信息。
[root@localhost /]#vim /usr/local/nagios/etc/objects/hosts.cfg
5、在nagios的services.cfg文件中添加需要检测的服务。
[root@localhost /]#vim /usr/local/nagios/etc/objects/services.cfg
6、执行“nagios -v”命令检测配置文件语法是否正确。
[root@localhost /]#/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
7、重新加载nagios服务
8、访问nagios的web界面,可以发现能够监控指定服务器的运行情况。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com