《nagios-nrpe监控远程主机》由会员分享,可在线阅读,更多相关《nagios-nrpe监控远程主机(5页珍藏版)》请在金锄头文库上搜索。
1、nagios nrpe监控远程主机 Nagios NRPE监控远程主机具体步骤如下。1. 监控机的软件的安装监控机安装NRPE wget /sourceforge/nagios/nrpe-2.12.tar.gz tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure -prefix=/usr/local/nagios make all make install-plugin#监控机只需安装到这步2. 被监控机的软件的安装被监控机添加用户groupadd nagiosuseradd -g nagios -d /usr/local/nagios -s
2、/sbin/nologin nagios被监控机安装pluginwget /sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gztar zxf nagios-plugins-1.4.13.tar.gzcd nagios-plugins-1.4.13./configure -with-nagios-user=nagios -with-nagios-group=nagios -prefix=/usr/local/nagios -with-ping-command=/bin/ping -with-mysql=/opt/mysqlmakemake in
3、stall#查看播件文件是否已安装在这个目录ls /usr/local/nagios/libexec被监控机安装NRPEwget /sourceforge/nagios/nrpe-2.12.tar.gz tar zxvf nrpe-2.12.tar.gzcd nrpe-2.12./configure -prefix=/usr/local/nagiosmake allmake install-pluginmake install-daemonmake install-daemon-configcp init-script /etc/init.d/nagios-nrpechown -R nagio
4、s:nagios /usr/local/nagios3. 被监控机的配置配置 NRPE:vi /usr/local/nagios/etc/nrpe.cfgallowed_hosts=127.0.0.1,192.168.1.91#Nagios监控机的地址或域名修改/etc/hosts.allow增加监控机ipecho nrpe:192.168.1.91 /etc/hosts.allow启动 NRPE 守护进程:/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d可以将此命令加入 /etc/rc.local ,以便开机自动启
5、动。echo /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d /etc/rc.local检查 NRPE 是否正常:/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1查看相应的端口:netstat -an |grep 5666防火墙开启5666 允许局域网IP或固定IP连接在监控主机上/usr/local/nagios/libexec/check_nrpe -H $目标主机地址都应该可以输出 NRPE 的版本: NRPE v2.12检查可监控的服务在被监控端的 nrpe
6、.cfg 文件中,可以看到这样的配置:commandcheck_load=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20这是用来检查 CPU 负载的。如果需要自定参数则使用下面命令commandcheck_load=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$ 并开启dont_blame_nrpe =1开启参数将会带来一定的安全风险被监控机重启nrpeps aux|grep nrpekill $pid/usr/local/nagios/bin/nrpe -
7、c /usr/local/nagios/etc/nrpe.cfg d4. 监控机设置在监控机commands.cfg 添加nrpe的定义 # check_nrpe command definition define command command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 增加hostA.cfg 在/usr/local/nagios/etc/objects/ 目录下新建文件:hostA.cfg 把A.cfg添加到nagios主机:echo cfg_file=/usr/lo
8、cal/nagios/etc/objects/hostA.cfg /usr/local/nagios/etc/nagios.cfg如果要再添加B机器方法炮制就可以了hostA.cfgdefine hostuse generic-serverhost_name Aalias Aaddress A 的IPdefine serviceuse generic-servicehost_name Aservice_description loadcheck_command check_nrpe!check_load#使用自定参数#check_command check_nrpe!check_load!6.
9、0,5.0,4.0!15.0,8.0,6.0重启监控机nagiosservice nagios reload访问http:/localhost/nagios就可以看到新增的机器了如何修改nrpe端口被监控机nrpe.cfg修改server_port为15666server_port=15666重启nrpe监控机commands.cfg增加-p 15666define commandcommand_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 15666 -c $ARG1$ 重启nagios就可以了Conne
10、ction refused or timed out检查nrpe 端口检查nrpe.cfg中allowed_hosts是否包含监控机ip地址检查/etc/hosts.allow文件中监控机ip地址nrpe:192.168.1.91检查iptables开放5666端口iptables -Liptables -A RH-Firewall-1-INPUT -p tcp -m state -state NEW -m tcp -dport 5666 -j ACCEPT#注意顺序iptables -Lservice iptables saveservice iptables restart通过文章,我们不
11、难发现Nagios NRPE监控远程主机操作非常简单!Question 1: When I execute check_nrpe command with some arguments, I get the message“CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.”. How do I fix this issue?Answer 1: The issue is very straight forward. check_nrpe doesnt take any arguments by default. You should enable the command line arguments for check_nrpe as shown below.1. Configure NRPE with enable-command-args2. Modify nrpe.cfg and set dont_blame_nrpe-全文完-