`
丶安颜丨
  • 浏览: 16454 次
  • 性别: Icon_minigender_1
  • 来自: 淮安
社区版块
存档分类
最新评论

基于nagios的监控环境(二):nrpe监控远程机器

阅读更多

Nagios监控环境安装http://teartao.iteye.com/blog/2172336

nagios监控网络流量、CPU、内存、进程插件http://teartao.iteye.com/blog/2173109

 

在前面两篇博文中介绍了nagios监控环境的安装,但nagios本身没有监控功能,且nagios plugins很多也是不支持远程监控的,所以我们需要安装nrpe对远程机器进行监控。下面步骤便是nrpe的安装过程:

 

 相关附件下载链接:

链接: http://pan.baidu.com/s/1pJODHvd 密码: ygs9

 

一、监控机安装:

check_nrpe也相当于nagios plugins的一种,它只提供了远程监控功能,而不具有对本机其它性能参数进行监控功能,所以安装check_nrpe之前,监控机必须安装nagios core。

 

1、check_nrpe安装:

#用yum命令安装系统组建以满足插件的安装环境
yum -y install openssl-devel
#cd /home/taolei/copy/pkg/
 
#进入安装包所在目录,解压并进入解压文件夹
rm -rf nrpe-2.15
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
 
 
#编译安装
./configure
make all
make install-plugin
     
#开启防火墙端口,以便远程的被监控机访问(这里是为了本机测试使用)
/sbin/iptables -I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
#保存防火墙配置:
/etc/rc.d/init.d/iptables save
#重启防火墙
/etc/rc.d/init.d/iptables restart
 
#通过监测命令测试check_nrpe插件检查插件版本来反映插件是否安装完成
#假设本监控机IP 192.168.52.132,被监控机(远程机)ip为192.168.52.131
#本机开启了防火墙的端口号可以通过如下命令检查本地插件版本
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
 
#若已有远程机安装了nrpe daemon 则可以使用如下命令检查远程机nrpe版本
/usr/local/nagios/libexec/check_nrpe -H 192.168.52.131

 

2、常见问题:

【问题描述】:被监控机已安装nrpe daemon,监控机输入

/usr/local/nagios/libexec/check_nrpe -H 192.168.xx.xx时,返回错误信息:CHECK_NRPE: Error - Could not complete SSL handshake. 或  connect to  refused 

【解决方法】:检查被监控机上/etc/xinetd.d/nrpe文件中的only_from/usr/local/nagios/etc/nrpe.cfg文件中allowed_hosts是否已配置监控机IP,若已配置监控机IP,确认防火墙是否重启过,重启命令如下/etc/init.d/xinetd restart

 

 

二、被监控机(远程机)安装:

 

 

1、nrpe daemon安装:

yum -y install openssl-devel xinetd
chown nagios:nagios /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios/libexec
 
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
 
#编辑/etc/xinetd.d/nrpe文件
nano /etc/xinetd.d/nrpe
 
#在only_from 后面加上nagios core所在的监控机ip,与前一ip之间用空白隔开
#only_from       = 127.0.0.1 <nagios_ip_address>  ,如:
#only_from       = 127.0.0.1 129.168.52.132
 
#编辑/etc/services 文件
nano /etc/services
 
#在其中加入NRPE端口的配置
nrpe            5666/tcp                        # NRPE
 
#开启防火墙5666端口
    /sbin/iptables -I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
 
#保存防火墙配置:
    /etc/rc.d/init.d/iptables save
 
#编辑nrpe.cfg文件
    nano /usr/local/nagios/etc/nrpe.cfg
 
#找到allowed_hosts = 127.0.0.1,在后面加入监控机的ip,如:
    allowed_hosts = 127.0.0.1,192.168.52.132

 

2、常见安装问题:

【问题描述】按照NRPE安装文档的步骤输入make all命令时,提示

make: *** No rule to make target `all'.  Stop.

【解决方法】安装openssl-devel:yum -y install openssl-devel

重新执行./configure命令后,再执行make all命令,即可解决

 

【问题描述】按照官方文档步骤,输入/usr/local/nagios/libexec/check_nrpe -H localhost命令时,报错提示:CHECK_NRPE: Error - Could not complete SSL handshake.

【解决方法】将localhost也添加至/etc/xinetd.d/nrpe文件中的only_from=后面,即

only_from  = 127.0.0.1 localhost

 

【问题描述】按照NRPE安装文档的步骤输入iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 5666 -j ACCEPT命令时报错

【解决方法】官方文档中上述命令书写有误,改为/sbin/iptables –I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT 即可 

 

#修改配置文件后需要重启nrpe
pkill nrpe;
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics