Chinaunix首页 | 论坛 | 博客
  • 博客访问: 507077
  • 博文数量: 105
  • 博客积分: 4174
  • 博客等级: 上校
  • 技术积分: 1395
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-07 11:35
文章分类

全部博文(105)

文章存档

2013年(3)

2012年(16)

2011年(71)

2010年(3)

2009年(6)

2008年(6)

分类: LINUX

2009-11-10 09:31:53

1. 在需要被监控的linux 主机上创建nagios用户
su -l
/usr/sbin/useradd nagios
passwd nagios

2. 下载安装nagios-plugins

链接:

tar xzf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
Compile and install the plugins.
./configure
make
make install

需要设置下相关权限:
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

3. 安装NRPE服务

链接:

tar xzf nrpe-2.8.tar.gz
cd nrpe-2.8
Compile the NRPE addon.
./configure

如果出现如下错误:checking for SSL headers... configure: error: Cannot find ssl headers

请安装openssl-devel包即可!


make all
Install the NRPE plugin (for testing), daemon, and sample daemon config file.

make install-plugin
make install-daemon
make install-daemon-config

Install the NRPE daemon as a service under xinetd.
make install-xinetd

编辑/etc/xinetd.d/nrpe添加Nagios服务器端的的地址到only_from.
only_from       = 172.18.127.48

添加nrpe服务端口到/etc/services中.
nrpe            5666/tcp # NRPE

重启nrpe服务
Restart the xinetd service.
service xinetd restart

测试端口是否有正常监听
# netstat -at |grep nrpe
tcp        0      0 *:nrpe                      *:*                         LISTEN
# netstat -ant |grep :5666
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN

检测NRPE服务是否有正常工作,此处需要only_from=127.0.0.1,才能测试通过
/usr/local/nagios/libexec/check_nrpe -H localhost
You should get a string back that tells you what version of NRPE is installed, like this:

NRPE v2.8

4. 自定义NRPE命令
vi /usr/local/nagios/etc/nrpe.cfg

这里先使用默认的一些设置
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs


5. 服务器端设置

服务器端安装NRPE,就是用先前的包即可

tar xzf nrpe-2.8.tar.gz
cd nrpe-2.8
Compile the NRPE addon.
./configure
make all
Install the NRPE plugin.
make install-plugin
不需要安装daemon可daemon的配置了

测试下与客户端NRPE daemon的通讯
/usr/local/nagios/libexec/check_nrpe -H xxx.xxxx.xxx.xxx(客户端的地址)
这里测试时,要确定客户机的only_from已经从127.0.0.1改为了服务器端的IP地址
否则,SSL是过不去的!


6. 定义服务器端配置

定义command:
vi /usr/local/nagios/objects/command.cfg

加入以下行:
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }

定义配置文件中的host及service

vi /usr/local/nagios/objects/localhost.cfg

增加host定义:
define host{
        use                     linux-server
        host_name               winbak
        alias                   winbak
        address                 172.18.127.163
        check_command           check-host-alive
        max_check_attempts      10
        notification_interval   120
        notification_period     24x7
        notification_options    d,r
        contact_groups  admins
        }


增加service定义:
define service{
        use                             local-service
        host_name                       winbak
        service_description             CPU Load
        check_command                   check_nrpe!check_load
        }

define service{
        use                             local-service
        host_name                       winbak
        service_description             Current Users
        check_command                   check_nrpe!check_users
        }

define service{
        use                             local-service
        host_name                       winbak
        service_description             Total Processes
        check_command                   check_nrpe!check_total_procs
        }

define service{
        use                             local-service
        host_name                       winbak
        service_description             Zombie Processes
        check_command                   check_nrpe!check_zombie_procs
        }

重启nagios
service nagios restart

阅读(1364) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~