0

I try to get some strings from avaya phone using pysnmp

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()))

But i get this:

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

If i use snmpwalk it work ok

[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

Why it work wrong and how can I fix it? I use python 2.7.11 and pysnmp 4.3.1

  • If you try snmpwalk multiple times, will it return the same results? I'm wondering if the values are dynamic. On a side note, I'd advise using a more modern pysnmp.hlapi API. – Ilya Etingof Dec 18 '15 at 09:00
  • If you mean multiple getCmd() - it return correct values. Values are static, I get OIDs from MIB. – Dmitriy Pyryakov Dec 19 '15 at 09:34
  • MIB can only have the IDs of the objects. The actual objects (e.g. the values you receive) are supplied by SNMP agent. Some of these values can change over time (example: interface traffic counters). Since you seem to get different results from snmpwalk and pysnmp GET, my guess was that the values are changing between your calls. – Ilya Etingof Dec 20 '15 at 11:33
  • Its not true becuse I try to get mac address, serial number, phone model and part number. Only last OID return variable. If I use first four OIDs (STRINGs) - I get the same bad result. – Dmitriy Pyryakov Dec 21 '15 at 04:10

0 Answers0