我试图使用python的pysnmp库来获取snmp数据。在数据中,一些COUNTER64对象可用,但无法检索。
命令 -
snmpwalk -v 1 -c public <ip address>:<port> xyz::pqr
输出 -
.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.12.1 = Counter64: 2761552407
.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.12.2 = Counter64: 0
.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.12.3 = Counter64: 0
.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.13.1 = Counter64: 2299496
.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.13.2 = Counter64: 0
.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.13.3 = Counter64: 0
使用pysnmp -
from pysnmp.hlapi import *
for (errorIndication,
errorStatus,
errorIndex,
varBinds) in nextCmd(SnmpEngine(),
CommunityData('public', mpModel=0),
UdpTransportTarget(('ip', port)),
ContextData(),
ObjectType(ObjectIdentity('.1.3.6.1.4.1.16136.13.5.1.200.1.51.1.12'))):
if errorIndication or errorStatus:
print(errorIndication or errorStatus)
break
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
输出 -
No SNMP response received before timeout
如何检索COUNTER64对象?我错过了什么吗?
答案 0 :(得分:1)
您只能使用SNMP版本2c和3上的Counter64值.SNMP版本1不支持RFC。
要将pysnmp切换为SNMPv2c,只需设置mpModel=1
或删除mpModel
参数即可使用默认值(即v2c)生成pysnmp。
这是doc。