我使用以下简单脚本:
from pysnmp.entity.rfc3413.oneliner import cmdgen
errorIndication,errorStatus,errorIndex,
varBindTable = cmdgen.CommandGenerator().bulkCmd(
cmdgen.CommunityData('test-agent','public'),cmdgen.UdpTransportTarget(('IP.IP.IP.IP',161)),1,(1,3,6,2,4,24,169,254)
)
if errorIndication:
print errorIndication
else:
if errorStatus:
print '%s at %sn' % (
errorStatus.prettyPrint(),errorIndex and varBindTable[-1][int(errorIndex)-1] or '?'
)
else:
for varBindTableRow in varBindTable:
for name,val in varBindTableRow:
print '%s = %s' % (name.prettyPrint(),val.prettyPrint())
从命令行使用snmpwalk到此设备返回预期结果.但
脚本返回超时前未收到SNMP响应.如果我省略这个OID,那么一切正常.
所以问题在于这个OID
这里tcpdump统计:
/usr/sbin/tcpdump -nn -vv -s0 -A host HOST and udp
tcpdump: listening on eth0,link-type EN10MB (Ethernet),capture size 65535 bytes
12:15:31.494920 IP (tos 0x0,ttl 64,id 0,offset 0,flags [DF],proto: UDP (17),length: 77) IP.IP.IP.IP.47911 > IP.IP.IP.IP.161: [bad udp cksum 4b7d!] { SNMPv2c { GetBulk(34) R=8993731 N=0 M=1 .1.3.6.1.2.1.4.24.4.1.2.169.254 } }
E..M..@.@.I..]<..]