本文所用到的监控流量插件来自”石头”的 1.20 版 shell 插件。感谢之。。。。

下载地址为: 点击下载 。 总体设置可以分为两块, linux 主机及非 linux 主机。稍有出入。不多说直接上配置

一、 linux主机

主要步骤:

1、安装snmpd服务软件包并设置启动之。

2、上传监控插件至被监控机nagios/libexec目录并授权

3、网卡参数检测

4、 nrpe.cfg文件增加监控command

5、 nagios服务器配置service.cfg添加监控项

具体实施:

1、 安装修改启动snmpd服务

安装:[root@nagios nagios]# yum -y install net-snmp*

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Setting up Install Process

Package 1:net-snmp-devel-5.3.2.2-9.el5_5.1.i386 already installed and latest version

Package 1:net-snmp-libs-5.3.2.2-9.el5_5.1.i386 already installed and latest version

Package 1:net-snmp-utils-5.3.2.2-9.el5_5.1.i386 already installed and latest version

Package 1:net-snmp-perl-5.3.2.2-9.el5_5.1.i386 already installed and latest version

Package 1:net-snmp-5.3.2.2-9.el5_5.1.i386 already installed and latest version

Nothing to do

#我已经安装过了。。就上面这些包了。。

修改snmpd.conf

# sec.name source community

com2sec notConfigUser 127.0.0.1(localhost也可不改) XXXX(共同体名)

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

access notConfigGroup “” any noauth exact mib2 none none

#改system为mib2

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

#去掉前面的”#”注释符

2、上传插件被授权

上传check_traffic.sh至/usr/local/nagios/libexec

改属主为:nagios

chown nagios.nagios ./check_traffic.sh

3、网卡参数检测:

[root@OAServer etc]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -L

List Interface for host 127.0.0.1.

Interface index 1 orresponding to lo

Interface index 2 orresponding to bond0

Interface index 3 orresponding to eth0

Interface index 4 orresponding to eth1

Interface index 5 orresponding to sit0

可以测试是否能够正常采集到数据

/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 1200,1500 -c 1700,1800 -K -b

OK – The Traffic In is 356Kbps, Out is 414Kbps, Total is 770Kbps. The Check Interval is 30s |In=356Kbps;1200;1700;0;0 Out=414Kbps;1500;1800;0;0 Total=770Kbps;2700;3500;0;0 Interval=30s;1200;1800;0;0

注:-V snmp协议版本

-C 共同体名

-I 参数对应上面-L输出的网卡index值。标示监视相应的网卡。

该插件其它使用方法及各参数解释详情”-help”或者看上面论坛石头描述

更改/var/tmp/check_traffic* 文件权限为nagios用户可读写。简单的给个777吧。。

chmod 777 /var/tmp/check_traffic_127.0.0.1_2.hist_dat_root__32

4、 更改nrpe.cfg增加如下行:

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

重启nrpe程序

[root@OAServer ~]# ps aux |grep nrpe

nagios 2822 0.0 0.0 4808 1448 ? Ss Jun01 0:04 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

root 1123 0.0 0.0 5936 736 pts/2 S+ 11:02 0:00 grep nrpe

[root@OAServer ~]# kill -9 2822

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

5、nagios服务器(监控端)编辑service.cfg增加监控网卡流量项目;

define service{

host_name WEB

service_description check_traffic

check_command check_nrpe!check_traffic

max_check_attempts 5

normal_check_interval 3

retry_check_interval 2

check_period 24×7

notification_interval 10

notification_period 24×7

notification_options w,u,c,r

contact_groups sagroup

}

二、其它设备:(win主机、交换、路由、防火墙)

这些主机上都是没办法安装nrpe插件的。所 以我们只有通过snmp协议采集。(两者异同之处就在于snmp数据报文是否在网络传输。前者snmp数据只会在本机产生,自己采集自身数据而后由 nrpe插件传输到nagios服务器前端显示出来(数据文件在本机)。后者则是nagios服务器通过snmp协议采集目标主机信息而后前端显示(数据 文件在服务器)。就安全性而言,前者更优于后者。

主要步骤:

1、设置主机snmp协议(共同体名、权限、trap目标主机)

2nagios服务器snmp连接测试及网卡参数确定

3nagios服务器commands.cfg配置

4service.cfg监控项目添加

5、重启nagios服务测试

具体实施:

演示设备:windows2003、netscreen防火墙、H3C路由以及H3C交换机。

1、 设置主机snmp协议

Windows主机:添加snmp组件。。在服务里找到”snmp service”编辑如下:

防火墙:

路由器:

交换机:

snmp-agent

snmp-agent local-engineid 800063A2000FE2CCFAA36877

snmp-agent community write XXXXX

snmp-agent sys-info version all

snmp-agent target-host trap address udp-domain XXXXXX params securityname XXXXX

1、 nagios服务器snmp连接测试及网卡参数确定:

以防火墙为例,找到个接口参数:

[root@nagios nagios]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C ksense -H 192.168.20.254 -L

List Interface for host 192.168.20.254.

Interface index 1 orresponding to ethernet0/0

Interface index 2 orresponding to ethernet0/1

Interface index 3 orresponding to ethernet0/2

Interface index 4 orresponding to ethernet0/3

Interface index 5 orresponding to vlan1

注意:index 后数字和网卡对应关系。后面写service.cfg时需用到。

2、 配置commands.cfg增加如下内容:

[root@nagios nagios]# tail -8 /usr/local/nagios/etc/commands.cfg

#######################################################################

#

#check_traffic

#

#######################################################################

define command{

command_name check_traffic

command_line $USER1$/check_traffic.sh -V 2c -C ksense -H $HOSTADDRESS$ -I $ARG1$ $ARG2$ $ARG3$ -K -B

}

3、 service.cfg监控项目添加:

以防火墙设备为例,其它方法相同

define service{

host_name juniper-ssg-320

service_description check_traffic_trust

check_command check_traffic!1 -w 600,600 -c 800,800

#注:叹号后面数据对应上面的”$ARG1$ $ARG2$ $ARG3$”3个字段,中间空格隔开

max_check_attempts 5

normal_check_interval 3

retry_check_interval 2

check_period 24×7

notification_interval 10

notification_period 24×7

notification_options w,u,c,r

contact_groups sagroup

}

define service{

host_name juniper-ssg-320

service_description check_traffic_DMZ

check_command check_traffic!2 -w 600,600 -c 800,800

max_check_attempts 5

normal_check_interval 3

retry_check_interval 2

check_period 24×7

notification_interval 10

notification_period 24×7

notification_options w,u,c,r

contact_groups sagroup

}

define service{

host_name juniper-ssg-320

service_description check_traffic_untrust1

check_command check_traffic!3 -w 600,600 -c 800,800

max_check_attempts 5

normal_check_interval 3

retry_check_interval 2

check_period 24×7

notification_interval 10

notification_period 24×7

notification_options w,u,c,r

contact_groups sagroup

}

define service{

host_name juniper-ssg-320

service_description check_traffic_untrust2

check_command check_traffic!4 -w 600,600 -c 800,800

max_check_attempts 5

normal_check_interval 3

retry_check_interval 2

check_period 24×7

notification_interval 10

notification_period 24×7

notification_options w,u,c,r

contact_groups sagroup

}

5、

[root@nagios nagios]# !1025

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

………………

Total Warnings: 0

Total Errors: 0

检查下配置文件是否有报错。。。没有就重启nagios服务即可生效了。

监控效果图:

Pnp图形:

转载于:https://www.cnblogs.com/huangjingzhou/articles/2140122.html

Nagios 网卡流量监控相关推荐

  1. c#利用PerformanceCounter进行网卡流量监控

    PerformanceCounter基础知识: 参考 Performance Counter的使用 利用PerformanceCounter进行网卡流量监控 方法一:利用PerformanceCoun ...

  2. Linux网卡限速下载,端口限速下载脚本,网卡流量监控脚本

    限速脚本:命令 "./limitRate.sh help (帮助)" "./limitRate.sh stop (停止限速)"  "./limitRa ...

  3. shell脚本实现对网卡流量监控

    文章来源:http://blog.chinaunix.net/uid-108431-id-3256066.html 突然想对linux的网卡流量进行监控,又不想使用cacti,觉得配置snmp很麻烦. ...

  4. iftop工具(网卡流量监控软件)的使用

    直接运行iftop,不加任何参数 界面显示 界面上面显示的是类似刻度尺的刻度范围,为显示流量图形的长条作标尺用的. 中间的<= =>这两个左右箭头,表示的是流量的方向. TX:发送流量 R ...

  5. Linux日常运维管理技巧(一)监控系统状态、监控网卡流量、监控IO性能、查看系统进程、查看网络状态、Linux下抓包tcpdump、Linux网络相关、DNS配置

    目录 监控系统状态 监控网卡流量 监控IO性能 查看系统进程 查看网络状态 Linux下抓包 Linux网络相关 监控系统状态 w/uptime查看系统负载 [root@zyshanlinux-01 ...

  6. 【网络】流量监控 - iftop|ifstat|查看某个ip流量|tcpdump|iptraf|Linux

    目录 流量监控18个常用工具 tcpdump查看某个端口数据 ifstat iftop 四.运行iftop 五.相关参数及说明 1.iftop界面相关说明 2.iftop相关参数 常用的参数 按端口显 ...

  7. html网络流量监控,Mrtg 网络流量监控

    #Cdp run 启用CDP #snmp-server community cisco ro(只读) :配置只读通信字符串为cisco #snmp-server community secret rw ...

  8. nagios监控mysql主机,nginx,cpu,网卡流量

    nagios安装完成,打开/usr/local/nagios/etc/nagios.cfg去掉cfg_dir=/usr/local/nagios/etc/servers前面的#号,并创建/usr/lo ...

  9. nagios监控告警之网络流量监控(附pnp模板)

    步骤: 1.下载网络流量监控脚本: https://raw.githubusercontent.com/June-Wang/NagiosPlugins/master/check_net_traffic ...

最新文章

  1. 八大基本数据类型对应的八大包装类(含对应面试题解析)
  2. 让那些为Webkit优化的网站也能适配IE10(转载)
  3. CYQ.Data 轻量数据访问层(八) 自定义数据表实现绑定常用的数据控件(中)
  4. 易语言多级指针读取_C语言指针难吗?纸老虎而已,纯干货讲解(附代码)
  5. calibration trl 设计_校准:怎样设计和验证TRL校准件以及TRL校准的具体过程
  6. Seata详解(二)
  7. lion.ec开源框架简介(原创)
  8. 洛谷 3959 宝藏——枚举+状压dp
  9. NOIP2017 普及组题解
  10. Spurious Local Minima are Common in Two-Layer ReLU Neural Networks
  11. 格式工厂 vtt字幕 加入视频
  12. TPS和QPS 并发量区别;日活 访问量 活跃度
  13. python str转bool方法
  14. 以leds-gpio.c为例,浅谈class、bus和platform子系统
  15. 【电子产品】ThinkPad S5 Intel R Dual Band Wireless-AC 3165 网卡驱动莫名
  16. [JavaSE基础笔记]Day10 石头迷阵实现
  17. 推荐5个好用的开源日志分析工具 (转载)
  18. JDK17的安装教程
  19. 企业做好私域电商的六大关键点
  20. 强迫症福音:OC启动界面图标与文字全部匹配超简单教程

热门文章

  1. 设备控制接口(ioctl 函数)
  2. 使用OpenCV-Python的函数minMaxLoc()应该注意的两点
  3. linux网卡绑定lacp,服务器网卡绑定为LACP 802.3ad,交换机是应该配置链路聚合吗?...
  4. Windows下使用gvim格式化xml文件
  5. leetcode算法题--两数相加 II
  6. linux搭建--centos使用qemu-kvm,libvirt搭建虚拟机,并搭建libvmi来虚拟机自省(四)
  7. 『追捕盗贼 Tarjan算法』
  8. Python全栈 MySQL 数据库 (索引、数据导入、导出)
  9. 以太坊智能合约开发第七篇:智能合约与网页交互
  10. 基于MVC4+EasyUI的Web开发框架经验总结(13)--DataGrid控件实现自己主动适应宽带高度...