getCmd工作错误

时间:2015-12-17 11:58:53

标签: python-2.7 net-snmp pysnmp avaya

我尝试使用pysnmp从avaya手机获取一些字符串

from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
    cmdgen.CommunityData('public'),
    cmdgen.UdpTransportTarget(('<ipaddr>', 161)),
    '1.3.6.1.4.1.6889.2.69.3.1.43.0',
    '1.3.6.1.4.1.6889.2.69.3.1.45.0',
    '1.3.6.1.4.1.6889.2.69.3.1.46.0',
    '1.3.6.1.4.1.6889.2.69.3.1.42.0',
    '1.3.6.1.4.1.6889.2.69.3.6.6.0'
)

if errorIndication:
    print(errorIndication)
else:
    if errorStatus:
        print('%s at %s' % (
            errorStatus.prettyPrint(),
            errorIndex and varBinds[int(errorIndex)-1] or '?'
            )
        )
    else:
        for name, val in varBinds:
            print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))

但我明白了:

SNMPv2-SMI::enterprises.6889.2.69.3.1.43.0 = B0:AD:AA
SNMPv2-SMI::enterprises.6889.2.69.3.1.45.0 = B0:AD:AA:
SNMPv2-SMI::enterprises.6889.2.69.3.1.46.0 = B0:AD:AA:3D:
SNMPv2-SMI::enterprises.6889.2.69.3.1.42.0 = B0:AD:AA:3D:3D:3C
SNMPv2-SMI::enterprises.6889.2.69.3.6.6.0 = 4

如果我使用snmpwalk它可以正常工作

[root@hostname ~]# snmpwalk -cpublic -v2c <ipaddr> 1.3.6.1.4.1.6889.2.69.3.1.43.0
SNMPv2-SMI::enterprises.6889.2.69.3.1.43.0 = STRING: "1608D01A"
[root@hostname ~]# snmpwalk -cpublic -v2c <ipaddr> 1.3.6.1.4.1.6889.2.69.3.1.45.0
SNMPv2-SMI::enterprises.6889.2.69.3.1.45.0 = STRING: "700458532"
[root@hostname ~]# snmpwalk -cpublic -v2c <ipaddr> 1.3.6.1.4.1.6889.2.69.3.1.46.0
SNMPv2-SMI::enterprises.6889.2.69.3.1.46.0 = STRING: "14WZ09370467"
[root@hostname ~]# snmpwalk -cpublic -v2c <ipaddr> 1.3.6.1.4.1.6889.2.69.3.1.42.0
SNMPv2-SMI::enterprises.6889.2.69.3.1.42.0 = STRING: "B0:AD:AA:3D:3D:3C"
[root@hostname ~]# snmpwalk -cpublic -v2c <ipaddr> 1.3.6.1.4.1.6889.2.69.3.6.6.0
SNMPv2-SMI::enterprises.6889.2.69.3.6.6.0 = INTEGER: 4

为什么它工作错误,我该如何解决? 我使用python 2.7.11和pysnmp 4.3.1

0 个答案:

没有答案