****在被监控主机安装nrpe****

(1)在被监控主机上,增加用户和密码

useradd nagios

passwd nagios

(2)安装nagios插件

tar zxf nagios-plugins-1.4.15.tar.gz(nagios-plugins-1.4.15放任意位置,一般习惯放在/opt目录下)

cd nagios-plugins-1.4.15

./configure --prefix=/usr/local/nagios

make

make install

chown nagios:nagios /usr/local/nagios/

chown nagios:nagios /usr/local/nagios/libexec/ -R

(3.1)安装nrpe

tar zxf nrpe-2.12.tar.gz(nrpe-2.12.tar.gz放在任意位置,一般习惯放在/opt目录下)

cd nrpe-2.12

./configure(会默认安装在/usr/local/nagios目录下)

make all

make install-plugin

make install-daemon

make install-daemon-config

(3.2)修改nrpe.conf文件

修改以下内容,将nagios监控主机的ip添加到allowed_hosts字段

allowed_hosts=127.0.0.1,监控主机Ip

否则在监控主机上运行/usr/local/nagios/libexec/check_nrpe -H 远端被监控机ip

时会报以下错误CHECK_NRPE: Error - Could not complete SSL handshake.

(3.3)安装xinetd脚本

在nrpe-2.12目录下执行

make install-xinetd

编辑xinetd脚本

vi /etc/xinetd.d/nrpe

在only_from后面增加监控主机的地址,以空格间隔

only_from       = 127.0.0.1,监控主机Ip

编辑/etc/services文件,增加nrpe服务

vi /etc/services

# Local services

nrpe            5666/tcp                        # nrpe

(3.4)重启xinetd服务

/etc/init.d/xinetd restart

(3.5)启动nrpe服务

检查nrpe服务是否启动

#ps aux|grep nrpe

如果nrpe没有启动,启动nrpe服务

# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

再次查看nrpe是否已经启动,端口是否正常监听

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

(3.6)测试nrpe是否正常工作

/usr/local/nagios/libexec/check_nrpe -H localhost

NRPE v2.12(正确的返回值)

(3.7)查看nrpe的监控命令

cd /usr/local/nagios/etc/

vi 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

(3.8)在监控主机上检查nrpe是否可以练到远端的nrpe

在监控主机上运行

#/usr/local/nagios/libexec/check_nrpe -H 远端监控主机ip

NRPE v2.12(正确的返回值)

这样远端nrpe安装成功,并保证监控主机可以连接远端的nrpe

****安装check_traffic插件****

(1)下载chech_traffic.sh

chech_traffic.sh并不是nagios-plugins自带插件,所以需要自行下载

下载后,将chech_traffic.sh放在/usr/local/nagios/libexec/chech_traffic.sh

修改chech_traffic.sh的权限为777,用户及用户组为nagios

chmod 777 chech_traffic.sh

choen nagios:nagios chech_traffic.sh

(2)安装并配置chech_traffic.sh的依赖服务

脚本准本好以后

在执行

#/usr/local/nagios/libexec/chech_traffic.sh  -V 2c -C public -H ***.***.***.*** -I 2 -w 200,300 -c 400,500 -K -B

提示以下错误:

which: no snmpwalk in (/opt/jdk1.6.0_25/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/dell/srvadmin/bin:/opt/dell/srvadmin/sbin:/root/bin)

Can not found command snmpwalk in you system PATH: /opt/jdk1.6.0_25/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/dell/srvadmin/bin:/opt/dell/srvadmin/sbin:/root/bin, pleas check it

是因为chech_traffic.sh依赖snmp服务

(2.1)安装snmp

如果/etc/下已有snmp文件夹,说明snmp已经安装

若果没有,需要安装snmp

因为是redhat系统,首先选择rpm安装

下载对应版本的snmp

rpm -ivh net-snmp-5.3.2.2-7.el5.x86_64.rpm

提示:libsensors.so.3()(64bit) is needed by package 1:net-snmp-5.3.2.2-7.el5.x86_64

依赖libsensors.so.3()(依赖这个库是因为snmp来依赖其他的一些服务)

选择用yum安装,解决依赖库的问题

yum install net-snmp* -y

得知安装net-snmp依赖以下:

lm_sensors*;beecrypt*;elfutils*

下载相应的rpm包,或是使用yum安装以上,再使用

rpm -ivh net-snmp-5.3.2.2-7.el5.x86_64.rpm 安装,即可安装成功

安装成功后,会有/etc/snmp文件

(2.2)配置snmp.conf

修改以下:

# group context sec.model sec.level prefix read write notif

access notConfigGroup "" any noauth exact mib2 none none

##去掉下面此行行首注释#。

view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc

备注:有些情况是将snmp.conf里面的以下字段也进行了修改,添加了被监控主机ip

# sec.name source community
com2sec notConfigUser 被监控机ip public

修改了以后再被监控上运行

/usr/local/nagios/libexec/chech_traffic.sh  -V 2c -C public -H ***.***.***.*** -L

提示noresponse form ....

于是就将com2sec notConfigUser 被监控机ip public的被监控ip去掉以后,就可以正常运行了

(3)执行check_traffic.sh

/usr/local/nagios/libexec/chech_traffic.sh  -V 2c -C public -H ***.***.***.*** -I 2 -w 200,300 -c 400,500 -K -B

-I 2 监控的网卡(2是网卡多对应的index值)

-w 200,300 warning的范围

-c 400,500 critical的范围

-K -B是单位

-H 被监测流量的主机ip

使用/usr/local/nagios/libexec/chech_traffic.sh  -V 2c -C public -H ***.***.***.*** -L

可以查看主机的网卡对应的index值

Interface index 1 orrresponding to lo

Interface index 2 orrresponding to eth0

Interface index 3 orrresponding to eth1

使用ifconfig,如果你监控的网卡是eth1,那么-I的参数就是3,即,-I 3

如果执行

#/usr/local/nagios/libexec/chech_traffic.sh  -V 2c -C public -H ***.***.***.*** -I 2 -w 200,300 -c 400,500 -K -B

OK - It's the first time for this plugins run. We'll get the data from the next time

说明check_traffic.sh可以在被测机上正确执行了

(4)将check_traffic.sh命令添加到nrpe.conf中

command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H ***.***.***.*** -I 2 -w 200,300 -c 400,500 -K -B

保存,重启nrpe服务

在被监控机上执行

/usr/local/nagios/libexec/check_nrpe -H ***.***.***.*** -c check_traffic

可能会提示:

SERVICE ALERT: ***.***.***.***;;traffic;UNKNOWN;SOFT;3;Unknown - Read or Write File /var/tmp/check_traffic_***.***.***.***;_11.hist_dat_root__32 Error with user uid=517(nagios) gid=517(nagios) groups=517(nagios)

是因为以非nagios用户身份,手动测试执行过该脚本(也就是command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H ***.***.***.*** -I 2 -w 200,300 -c 400,500 -K -B这个操作),请在正式使用该脚本前,删除/var/tmp下对应测试生成的/var/tmp/check_traffic_${Host}_${Interface}.hist_dat文件,否则会造成nagios用户无法读写该文件的错误

删除/var/tmp/check_traffic_${Host}_${Interface}.hist_dat文件后

再次执行

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_traffic

可以看见流量的统计结果

(5)在监控主机上验证的被监控上的check_traffic.sh是否可以成功执行

在监控主机上执行/usr/local/nagios/libexec/check_nrpe -H ***.***.***.*** -c check_traffic

得到流量统计结果,可以将check_traffic配到监控主机的服务里面,在nagios上可以监控到远端主机的流量了

以上check_traffic.sh只能监控到某一个网卡的全部流量,一旦nagios流量过高,出现警告,如何排查那个进程所占用的流量

可以使用nethogs工具,可以监控某块网卡上每个进程的流量,可以使用nethogs工具自行写个脚本,监控你所关心的进程流量,配合check_traffic.sh插件使用

redhat--nagios插件--check_traffic.sh的更多相关文章

  1. nagios 配置 check_traffic 流量监控模块(被监控端)

    安装软件包yum -y install net-snmp*chkconfig nrpe onchkconfig snmpd on 使用SCP命令拷贝 check_traffic.sh 到 / usr/ ...

  2. nagios 配置 check_traffic 流量监控模块(Server 端)

    安装软件包yum -y install net-snmp*chkconfig nrpe onchkconfig snmpd onchkconfig nagios on 修改snmp参数,vi /etc ...

  3. 使用nagios插件 check_mysql_health 过程中遇到的error

    使用nagios插件 check_mysql_health 过程中遇到的error 1.如果在运行监控mysql插件的时候遇到了error安装以下依赖包就可以解决: yum install perl- ...

  4. nagios 插件ndoutils 安装配置

    nagios 插件ndoutils 安装配置 原文地址:http://www.cnblogs.com/caoguo/p/5022645.html # Nagios install ndoutils # ...

  5. nagios插件nagiosql安装配置

    nagios插件nagiosql安装配置 # Nagiosql install [root@Cagios ~]# yum install -y libssh2 libssh-devel [root@C ...

  6. nagios插件之登陆SBC监控电话数

    运行:sbc_calls_status_new auto_ssh_sbc_10_17.sh | auto_ssh_sbc_11_17.sh vi sbc_calls_status_new.c #inc ...

  7. nagios插件之登陆防火墙实现session监控

    ssh_firewall_session.sh -- 登陆防火墙并运行dis session statistics firewall_check_sessions.c -- 调用上面脚本.过滤出ses ...

  8. 用python 写一个nagios插件 监控http内容(转载)

     nagios自带的http-check插件主要是检测地址url是否可以访问,在web+中间件的架构中容易出现url能访问,但是后台中间件拓机的情况,因为最近在自学python,所以写了个脚本检测ur ...

  9. nagios插件之监控if8接口日志(新接口)

    vi check_if8_log.c #include <stdio.h> #include <stdlib.h> #include <string.h> #inc ...

随机推荐

  1. Proxmox虚拟机增加硬盘容量

    1.首先在虚拟机控制台选择调整硬盘容量,弹出窗口为增加的容量 2.重启虚拟机,用fdisk –l查看新增容量是否被识别 3.用cfdisk创建分区,分区格式为Primary 8e (Linux LVM ...

  2. android音乐播放器开发教程

    android音乐播放器开发教程 Android扫描sd卡和系统文件 Android 关于录音文件的编解码 实现米聊 微信一类的录音上传的功能 android操作sdcard中的多媒体文件——音乐列表 ...

  3. C# 知识笔记

    HttpContext.Request.Form.ToString() 获取Form表单中的内容 /// <summary> /// 获取 GET 提交方式值 /// </summa ...

  4. hdu 1133 Buy the Ticket

    首先,记50的为0,100的为1. 当m=4,n=3时,其中的非法序列有0110010; 从不合法的1后面开始,0->1,1->0,得到序列式0111101 也就是说,非法序列变为了n-1 ...

  5. Java 网络编程 字符流的发送与接收 自定义数据边界

    在网络编程中,客户端调用了flush方法,就会将缓存在字符流中的文本发送给服务器,服务器该怎样判断客户端发送的文本已经结束了呢? 我们先看一个例子: 客户端: import java.io.IOExc ...

  6. Jmeter 快速入门教程(三-1) --添加响应断言(即loadrunner中所指的检查点)

    [版权所有: whoistester.com & jmeter.cf] 上一节课,我们创建了一个测试场景,并进行了少量vuser的负载测试. 有时候我们执行了测试,但是发现并不是所有事务都执行 ...

  7. dynamic介绍

    Visual C# 2010 引入了一个新类型 dynamic. 该类型是一种静态类型,但类型为 dynamic 的对象会跳过静态类型检查. 大多数情况下,该对象就像具有类型 object 一样. 在 ...

  8. truncate、drop、delete区别

    速度:drop>truncate>delete 1.TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNCATE ...

  9. Floodlight中的临时流表

    运行Floodlight,在Mininet中新建一个拓扑之后,并未添加相关的流表项,但是主机之间却可以相互通信.执行pingall操作,任意两个主机之间都能通.相当于没有任何路由表的路由器,它是怎么让 ...

  10. 用Delphi创建服务程序

    用Delphi创建服务程序 日期:2005年11月29日 作者:sunmohe 人气: 3154 查看:[大字体 中字体 小字体] Windows 2000/XP和2003等支持一种叫做"服 ...