添加nagios linux监控机

配置nagios被监控机

操作方法:

1.  nagios服务器(以下称为监控机)和被监控机上部署

安装nrpe (监控机也安�b) tar �\zxvf nrpe�\***.tar.gz

cd nrpe�\2.8.1

./configure

make all

make install�\plugin

make install�\daemon

make install�\daemon�\config

/usr/local/nagios/libexec/check_nrpe �\H localhost

         安装nagios插件 tar �\zxvf nagios�\plugins�\***.tar.gz

cd nagios�\plugins�\***

./configure

make

make install

chown nagios.nagios /usr/local/nagios

chown �\R nagios.nagios /usr/local/nagios/libexec

客户端:

         客户端配置

所有机器都需要配置:

安装XINETD服务

yum -y install xinetd

chkconfig xinetd on

service xinetd start

添加 nagios 用户

useradd -s /sbin/nologin nagios

1.       安装 nrpe

tar zxvf nrpe-2.12.tar.gz

./configure && make all

make install-plugin

make install-daemon

make install-daemon-config

make install-xinetd

配置nrep

vi /etc/xinetd.d/nrpe

# default: on

# description: NRPE (Nagios Remote Plugin Executor)

service nrpe

{

        flags           = REUSE

        socket_type     = stream

        port            = 5666

        wait            = no

        user            = nagios

        group           = nagios

        server          = /usr/local/nagios/bin/nrpe

        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd

        log_on_failure  += USERID

        disable         = no

        only_from       = 127.0.0.1 serverip

}

3.添加端口

vi /etc/services 在最后添加

nrpe 5666/tcp #nrpe

 

4.重新启动Xinetd服务

/etc/init.d/xinetd restart

 

netstat -na | grep 5666

 

tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN

 

5.安装Nagios的插件nagios-plugin

tar zxvf nagios-plugins-1.4.13.tar.gz

cd nagios-plugins-1.4.13

./configure

make && make install

 

6、复制服务端的libexec到客户端

libexec 放在/usr/local/nagios/libexec 里面

 

7、配置/usr/local/nagios/etc/nrpe.cfg

修改以下值为:

server_address=serverip

allowed_hosts=127.0.0.1,serverip

 修改了nrpe.cfg后,需要重启一下  service xinetd restart

8、安装snmp

 yum install net-snmp

复制配置文件snmpd.conf

启动snmp service snmpd start

测试监控脚本

/usr/local/nagios/libexec/check_traffic_nv.sh -V 2c -C public -H localhost -I 3 -w 30,30 -c 50,50 -M –b

接下来就是监控端的配置了,因为时间有限 我在这里就只把服务端需要修改的部分大致写一下,就不详写了,也很简单,主要有2个地方需要明白注意

1.在服务器上你可以把所有客户端的监控配置文件放在一个目录当中,便于管理,这样需要在nagios.cfg文件中加入 cfg_dir=/usr/local/nagios/etc/service,不然你需要把每个客户端的配置文件都一条一条加到nagios.cfg中,工程量大,不便管理

2.客户端配置文件中主要注意,以下我逐条解释

define host{

use    linux-server    使用templates.cfg 的定义的host

host_name    Nagios53  随便起,将来在nagios web界面中对客户机的标识,和供下面自定义server调用

alias         Nagios   client   别名

address        192.168.203.50   被监控端的ip

}

 

define service{
        use                             local-service
        host_name                       Nagios53
        service_description             check_cpu
        check_command                   check_nrpe!check_cpu!5!70!90
        }

以上我主要解释下

check_command   check_nrpe!check_cpu!5!70!90 这里的check_cpu不是监控服务器libexec目录下的check_cpu,而是要对应被监控客户端nrpe.cfg定义的

command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh -i 5 -w 70 -c 90

这里必须对应,不然会报错,提示undefine

 

客户机中的cpu、disk、memory、swap等本地资源信息是靠nrpe传送到服务器的,同时需要开启snmp

 

好了,就到这里了,写的很冲忙,有什么不懂的,留言吧,在此深表歉意!!

 

你可能感兴趣的:(监控,nagios,check,nrpe,nagios-plugin)