部署Nagios监控系统(三)NRPE监控远程主机系统状况

来源:互联网 发布:mac文档保存在哪里 编辑:程序博客网 时间:2024/05/20 22:27

NRPE总共由两部分组成:
check_nrpe
插件:运行在监控主机上 (即nagios主机)
NRPE daemon
:运行在远程的linux主机上(通常就是被监控机)

205007588.jpg

当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-pluginsnrpe

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

230648382.jpg

修改上图中的内容,修改后如下图所示:

230859559.jpg

并添加如下选项,如果默认有的话则不用添加,添加没有的项即可。

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是否已经启动。

231206376.jpg

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、测试是否可以连接到被检测端。

231738905.jpg

3、在nagios的commands.cfg文件中添加nrpe命令。

[root@localhost /]#vim /usr/local/nagios/etc/objects/commands.cfg

231836976.jpg

4、在nagios的hosts.cfg文件中添加被监控端主机的相关信息。

[root@localhost /]#vim /usr/local/nagios/etc/objects/hosts.cfg

231924254.jpg

5、在nagios的services.cfg文件中添加需要检测的服务。

[root@localhost /]#vim /usr/local/nagios/etc/objects/services.cfg

232142409.jpg

232153943.jpg

233631475.jpg

232218762.jpg

6、执行“nagios -v”命令检测配置文件语法是否正确。

[root@localhost /]#/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg

232526523.jpg

7、重新加载nagios服务

232621990.jpg

8、访问nagios的web界面,可以发现能够监控指定服务器的运行情况。

235903397.jpg








本文出自 “邓奇的Blog” 博客,请务必保留此出处http://dengqi.blog.51cto.com/5685776/1272592

0 0
原创粉丝点击