10月 312014
 

查看系统日志,发现大量xinetd下nrpe日志

[root@localhost ~]# less /var/log/messages
 Oct 31 11:49:30 localhost xinetd[9646]: START: nrpe pid=10372 from=::ffff:192.168.153.110
 Oct 31 11:49:30 localhost xinetd[9646]: EXIT: nrpe status=0 pid=10372 duration=0(sec)
 Oct 31 11:51:15 localhost xinetd[9646]: START: nrpe pid=10642 from=::ffff:192.168.153.110
 Oct 31 11:51:15 localhost xinetd[9646]: EXIT: nrpe status=0 pid=10642 duration=0(sec)

修改配置文件,禁用成功状态下的日志

[root@localhost ~]# vi /etc/xinetd.conf
 # Define general logging characteristics.
                log_type        = SYSLOG daemon info
                log_on_failure  = HOST
 #              log_on_success  = PID HOST DURATION EXIT

nrpe-xinetd-log-disable

重新服务xinetd后再次查看日志,不再出现nrpe相关日志

Oct 31 11:52:05 localhost xinetd[9646]: Exiting...
Oct 31 11:52:05 localhost xinetd[10785]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
Oct 31 11:52:05 localhost xinetd[10785]: Started working: 1 available service
4月 172013
 

……

在监控主机端安装check_nrpe插件

[root@monitor ~]# tar xzvf nrpe-2.14.tar.gz
[root@monitor ~]# cd nrpe-2.14
[root@monitor nrpe-2.14]# ./configure
[root@monitor nrpe-2.14]# make all
[root@monitor nrpe-2.14]# make install-plugin
[root@monitor nrpe-2.14]# ls /usr/local/nagios/libexec/check_nrpe
 /usr/local/nagios/libexec/check_nrpe
[root@monitor nrpe-2.14]#

在被监控主机端安装nagios plugin与nrpe daemon

[root@localhost nrpe-2.14]# useradd nagios -s /sbin/nologin

安装nagios plugin

[root@localhost nagios-plugins-1.4.16]# ./configure
[root@localhost nagios-plugins-1.4.16]# make
[root@localhost nagios-plugins-1.4.16]# make install
[root@localhost nagios-plugins-1.4.16]# chown -R nagios.nagios /usr/local/nagios/

[root@localhost nrpe-2.14]# yum install gcc make openssl-devel

[root@localhost ~]# yum install xinetd

[root@localhost nrpe-2.14]# ./configure
[root@localhost nrpe-2.14]# make
[root@localhost nrpe-2.14]# make install
[root@localhost nrpe-2.14]# make install-daemon
[root@localhost nrpe-2.14]# make install-daemon-config
[root@localhost nrpe-2.14]# make install-xinetd

修改配置文件中NRPE监听的监控主机IP地址
[root@localhost nrpe-2.14]# vi /etc/xinetd.d/nrpe
only_from       = 127.0.0.1

[root@localhost nrpe-2.14]# vi /etc/services
nrpe            5666/tcp                # NRPE Daemon

[root@localhost nrpe-2.14]# service xinetd start
Starting xinetd:                                           [  OK  ]
[root@localhost nrpe-2.14]#

[root@localhost nrpe-2.14]# netstat -at |grep nrpe
tcp        0      0 *:nrpe                      *:*                         LISTEN
[root@localhost nrpe-2.14]#

[root@localhost nrpe-2.14]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.14
[root@localhost nrpe-2.14]#

在监控主机使用命令检测被监控主机当前登录用户数量

[root@monitor libexec]# ./check_nrpe -H 192.168.1.90 -c check_users
USERS OK – 1 users currently logged in |users=1;5;10;0
[root@monitor libexec]#

使用NRPE需要定义被监控主机所使用的命令
[root@localhost nrpe-2.14]# vi /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

在监控主机创建check_nrpe命令定义

# ‘check_nrpe’ command definition
define command{
command_name    check_nrpe
command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

增加被监控主机的监控服务定义

[root@monitor etc]# vi servers/szvs-v01.cfg
define service{
use                             generic-service
host_name                       szvs-v01
service_description             Current Users
check_command                   check_nrpe!check_users
}

define service{
use                             generic-service
host_name                       szvs-v01
service_description             CPU Load
check_command                   check_nrpe!check_load
}

nagios-nrpe-install-01 nagios-nrpe-install-02

相关下载:
(1) NRPE 2.14