Network-20181212-Juniper Device Per-Second Bandwidth

11 篇文章 0 订阅
11 篇文章 0 订阅

Problem

网上搜索到的 Input Bandwidth 计算方法普遍采用的思路为取单位时间内的平均值,即 (第 [n+m] 秒的 ifHCInOctets 存量值 - 第 [n] 秒的 ifHCInOctets 存量值) / m,这个在网络设备更新 ifHCInOctets 值的频率和 m 秒(单位时间)存在差距的时候,就会出现异常的数值抖动和不准确。

Solution

每秒带宽 MIB

可用 Juniper 设备的 MIB 库查询到直接的每秒出入带宽,如下:

  1. ifIn1SecRate
  • oid: 1.3.6.1.4.1.2636.3.3.1.1.1
  • The number of bits per second (bps), delivered by this (sub-)layer to its next higher (sub-)layer.
  1. ifIn1SecOctets
  • oid: 1.3.6.1.4.1.2636.3.3.1.1.2
  • The number of octets per second (Bps, Bytes per second), delivered by this (sub-)layer to its next higher (sub-)layer.
  1. ifHCIn1SecRate
  • oid: 1.3.6.1.4.1.2636.3.3.1.1.7
  • The number of bits per second (bps), delivered by this (sub-)layer to its next higher (sub-)layer. This object is a 64 bit version of ifIn1SecRate.
  1. ifHCIn1SecOctets
  • oid: 1.3.6.1.4.1.2636.3.3.1.1.34
  • The number of bytes per second (Bps), delivered by this (sub-)layer to its next higher (sub-)layer. This object is a 64 bit version of ifIn1SecOctets.

Oid Sample with netsnmp Python Library


import netsnmp

#---------------------------------------------------------------------------------------------
# deviceip		设备 ip
# interface	端口 index 号
#				*	形如以下:
#				*		Interface index: 166, SNMP ifIndex: 612
#				*		Logical interface et-2/3/0.0 (Index 353) (SNMP ifIndex 523)
#				*	则,取 612 为参数 interface 的值
#---------------------------------------------------------------------------------------------

def getinfo(deviceip, interface):
	"""get oid info"""
	session = netsnmp.Session(Version = 3, DestHost = deviceip, SecLevel = authPriv, SecName = securityname, PrivProto = privacyprotocol, PrivPass = privacyphrase, AuthProto = authenticationprotocol, AuthPass = authenticationphrase)
	varList = netsnmp.VarList(netsnmp.Varbind("ifDescr." + interface), netsnmp.Varbind(".1.3.6.1.4.1.2636.3.3.1.1.7." + interface), netsnmp.Varbind(".1.3.6.1.4.1.2636.3.3.1.1.8." + interface))
	values = session.get(varList)
	return values
	

Extends

Oid 数据类型

  1. Integer 整型
    Signed 32bit Integer (values between -2147483648 and 2147483647). 有符号32位整数(值范围: -2147483648 - +2147483648)
  2. Integer32
    Same as Integer. 与Integer相同。
  3. UInteger32
    Unsigned 32bit Integer (values between 0 and 4294967295). 无符号32位整数(值范围:0-4294967295).
  4. Octet String
    Arbitrary binary or textual data, typically limited to 255 characters in length. 任意二进制或文本数据,通常长度限制在255个字符内。
  5. Object Identifier
    An OID. 一个OID。
  6. Bit String
    Represents an enumeration of named bits. This is an unsigned datatype. 表示取名的位的枚举。这是一个无符号的数据类型。
  7. IpAddress
    An IP address. 一个IP地址。
  8. Counter32
    Represents a non-negative integer which monotonically increases until it reaches a maximum value of 32bits-1 (4294967295 dec), when it wraps around and starts increasing again from zero. 表示一个非负的整数(可递增到32位最大值-1),然后恢复并从0开始递增。
  9. Counter64
    Same as Counter32 but has a maximum value of 64bits-1. 与Counter32相同,最大值为64位的最大值-1。
  10. Gauge32
    Represents an unsigned integer, which may increase or decrease, but shall never exceed a maximum value. 表示无符号整数,可增加或减少,但是不超过最大值。
  11. TimeTicks
    Represents an unsigned integer which represents the time, modulo 2ˆ32 (4294967296 dec), in hundredths of a second between two epochs. 表示代表数据的一个无符号整数,2^32取模(4294967296),两个值之间为百分之一秒。
  12. Opaque
    Provided solely for backward-compatibility, its no longer used. 提供向下兼容,不再使用的数据类型
  13. NsapAddress
    Represents an OSI address as a variable-length OCTET STRING. 表示一个用变长八进制字符窗表示的OSI地址。

不同 Oid 数据类型 Sample

SNMPv2-SMI::enterprises.2636.3.3.1.1.2.111 = Gauge32: 7571581
SNMPv2-SMI::enterprises.2636.3.3.1.1.7.111 = Counter64: 60572648

这里的 Gauge32, Counter64 其实就是说明对应着不同的数据类型,和编程语言中理解的没啥大概念上的不同。(便于理解所谓的 64 bit 是啥意思,其实就是简单的一种数据类型罢了)

Reference

  1. Juniper Official MIB Search-ifIn1SecOctets
  2. SNMP介绍,OID及MIB库
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值