本文共 5968 字,大约阅读时间需要 19 分钟。
交换机MIB库中 MIB字符串对应的中文意思:
ifIndex 端口索引号 ifDescr 端口描述 ifType 端口类型 ifMtu 最大传输包字节数 ifSpeed 端口速度 ifPhysAddress 物理地址 ifOperStatus 操作状态 ifLastChange 上次状态更新时间
与流量相关的MIB字符串对应的中文意思:
ifInOctets 输入字节数 ifOutOctets 输出字节数 ifInUcastPkts 输入非广播包数 ifOutUcastPkts 输出非广播包数 ifInNUcastPkts 输入广播包数 ifOutNUcastPkts 输出广播包数 ifInDiscards 输入包丢弃数 ifOutDiscards 输出包丢弃数 ifInErrors 输入包错误数 ifOutErrors 输出包错误数
如何实现使用SNMP监控交换机端口带宽?
监控交换机端口带宽实际上就是监控端口入流量和出流量信息,若要监控端口流量信息就需要使用ifInOctets和ifOutOctets字符串;具体使用格式如下(手动获取端口流量,其中testPublic是community社区名称):[root@localhost ~]# snmpwalk -v 2c -c testPublic 172.16.100.1 ifInOctets IF-MIB::ifInOctets.1 = Counter32: 0 IF-MIB::ifInOctets.2 = Counter32: 0 IF-MIB::ifInOctets.3 = Counter32: 0 IF-MIB::ifInOctets.4 = Counter32: 0 IF-MIB::ifInOctets.6 = Counter32: 1619025492 IF-MIB::ifInOctets.7 = Counter32: 2463331598 IF-MIB::ifInOctets.8 = Counter32: 3630545960 IF-MIB::ifInOctets.9 = Counter32: 2570129655 IF-MIB::ifInOctets.10 = Counter32: 0 IF-MIB::ifInOctets.11 = Counter32: 2308743436 IF-MIB::ifInOctets.12 = Counter32: 401489415 IF-MIB::ifInOctets.13 = Counter32: 0 IF-MIB::ifInOctets.14 = Counter32: 0 IF-MIB::ifInOctets.15 = Counter32: 0 IF-MIB::ifInOctets.16 = Counter32: 1555109398 IF-MIB::ifInOctets.17 = Counter32: 0 IF-MIB::ifInOctets.18 = Counter32: 38671 IF-MIB::ifInOctets.19 = Counter32: 0 IF-MIB::ifInOctets.20 = Counter32: 0 IF-MIB::ifInOctets.21 = Counter32: 0 IF-MIB::ifInOctets.22 = Counter32: 0 IF-MIB::ifInOctets.23 = Counter32: 0 IF-MIB::ifInOctets.24 = Counter32: 0 IF-MIB::ifInOctets.25 = Counter32: 0 IF-MIB::ifInOctets.26 = Counter32: 3644608740 IF-MIB::ifInOctets.27 = Counter32: 0 IF-MIB::ifInOctets.28 = Counter32: 0 IF-MIB::ifInOctets.29 = Counter32: 2397532255 IF-MIB::ifInOctets.30 = Counter32: 0 IF-MIB::ifInOctets.31 = Counter32: 0 IF-MIB::ifInOctets.32 = Counter32: 0 IF-MIB::ifInOctets.33 = Counter32: 0 IF-MIB::ifInOctets.34 = Counter32: 0 IF-MIB::ifInOctets.35 = Counter32: 0 IF-MIB::ifInOctets.36 = Counter32: 0 IF-MIB::ifInOctets.37 = Counter32: 0 IF-MIB::ifInOctets.38 = Counter32: 0 IF-MIB::ifInOctets.39 = Counter32: 0 IF-MIB::ifInOctets.40 = Counter32: 0 IF-MIB::ifInOctets.41 = Counter32: 0 IF-MIB::ifInOctets.42 = Counter32: 0 IF-MIB::ifInOctets.43 = Counter32: 4082357090 IF-MIB::ifInOctets.44 = Counter32: 1905708319 IF-MIB::ifInOctets.45 = Counter32: 0 IF-MIB::ifInOctets.46 = Counter32: 0 IF-MIB::ifInOctets.47 = Counter32: 0 IF-MIB::ifInOctets.48 = Counter32: 0 IF-MIB::ifInOctets.49 = Counter32: 0 IF-MIB::ifInOctets.50 = Counter32: 0 IF-MIB::ifInOctets.51 = Counter32: 2710232851 IF-MIB::ifInOctets.52 = Counter32: 0
从上面可以看到,可以获取到52个接口的信息。那么,这就结束了?当然不是,实际上按照这个接口信息去统计流量信息是不正确的;因为这个交换机只有24个ethernet接口,8个光口,也就是说这个交换机实际的物理接口总共32个。但现在得到的接口却是52个,明显不正确。这种情况下该如何判断使用snmpwalk命令得到的接口相对应的物理接口是哪个?
这个时候可以使用ifDescr进行查看然后与上面的比对就可以知道了,具体用法如下(其中testPublic是community社区名称):
[root@localhost ~]# snmpwalk -v 2c -c testPublic 172.16.100.1 ifDescr IF-MIB::ifDescr.1 = STRING: InLoopBack0 IF-MIB::ifDescr.2 = STRING: NULL0 IF-MIB::ifDescr.3 = STRING: Console9/0/0 IF-MIB::ifDescr.4 = STRING: MEth0/0/1 IF-MIB::ifDescr.6 = STRING: GigabitEthernet0/0/1 IF-MIB::ifDescr.7 = STRING: GigabitEthernet0/0/2 IF-MIB::ifDescr.8 = STRING: GigabitEthernet0/0/3 IF-MIB::ifDescr.9 = STRING: GigabitEthernet0/0/4 IF-MIB::ifDescr.10 = STRING: GigabitEthernet0/0/5 IF-MIB::ifDescr.11 = STRING: GigabitEthernet0/0/6 IF-MIB::ifDescr.12 = STRING: GigabitEthernet0/0/7 IF-MIB::ifDescr.13 = STRING: GigabitEthernet0/0/8 IF-MIB::ifDescr.14 = STRING: GigabitEthernet0/0/9 IF-MIB::ifDescr.15 = STRING: GigabitEthernet0/0/10 IF-MIB::ifDescr.16 = STRING: GigabitEthernet0/0/11 IF-MIB::ifDescr.17 = STRING: GigabitEthernet0/0/12 IF-MIB::ifDescr.18 = STRING: GigabitEthernet0/0/13 IF-MIB::ifDescr.19 = STRING: GigabitEthernet0/0/14 IF-MIB::ifDescr.20 = STRING: GigabitEthernet0/0/15 IF-MIB::ifDescr.21 = STRING: GigabitEthernet0/0/16 IF-MIB::ifDescr.22 = STRING: GigabitEthernet0/0/17 IF-MIB::ifDescr.23 = STRING: GigabitEthernet0/0/18 IF-MIB::ifDescr.24 = STRING: GigabitEthernet0/0/19 IF-MIB::ifDescr.25 = STRING: GigabitEthernet0/0/20 IF-MIB::ifDescr.26 = STRING: GigabitEthernet0/0/21 IF-MIB::ifDescr.27 = STRING: GigabitEthernet0/0/22 IF-MIB::ifDescr.28 = STRING: GigabitEthernet0/0/23 IF-MIB::ifDescr.29 = STRING: GigabitEthernet0/0/24 IF-MIB::ifDescr.30 = STRING: GigabitEthernet0/0/25 IF-MIB::ifDescr.31 = STRING: GigabitEthernet0/0/26 IF-MIB::ifDescr.32 = STRING: GigabitEthernet0/0/27 IF-MIB::ifDescr.33 = STRING: GigabitEthernet0/0/28 IF-MIB::ifDescr.34 = STRING: GigabitEthernet0/0/29 IF-MIB::ifDescr.35 = STRING: GigabitEthernet0/0/30 IF-MIB::ifDescr.36 = STRING: GigabitEthernet0/0/31 IF-MIB::ifDescr.37 = STRING: GigabitEthernet0/0/32 IF-MIB::ifDescr.38 = STRING: Vlanif10 IF-MIB::ifDescr.39 = STRING: Vlanif20 IF-MIB::ifDescr.40 = STRING: Vlanif30 IF-MIB::ifDescr.41 = STRING: Vlanif40 IF-MIB::ifDescr.42 = STRING: Vlanif100 IF-MIB::ifDescr.43 = STRING: Eth-Trunk1 IF-MIB::ifDescr.44 = STRING: Eth-Trunk2 IF-MIB::ifDescr.45 = STRING: Vlanif200 IF-MIB::ifDescr.46 = STRING: Vlanif21 IF-MIB::ifDescr.47 = STRING: Vlanif22 IF-MIB::ifDescr.48 = STRING: Vlanif201 IF-MIB::ifDescr.49 = STRING: Vlanif202 IF-MIB::ifDescr.50 = STRING: Vlanif23 IF-MIB::ifDescr.51 = STRING: Eth-Trunk3 IF-MIB::ifDescr.52 = STRING: Vlanif66
可以看到有32个GigabitEthernet接口,8个光口也显示为GigabitEthernet的原因是这8个光口没有安装光模块,因此暂时显示为GigabitEthernet接口。
本文转自 f_066 51CTO博客,原文链接:http://blog.51cto.com/ganmu/2043635,如需转载请自行联系原作者