Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMP get on sysObjectID ends with AttributeError: prettyOut #47

Closed
cbueche opened this issue Jan 15, 2016 · 4 comments
Closed

SNMP get on sysObjectID ends with AttributeError: prettyOut #47

cbueche opened this issue Jan 15, 2016 · 4 comments

Comments

@cbueche
Copy link

cbueche commented Jan 15, 2016

operation : get sysObjectID from a Cisco switch

works on snimpy 0.8.1

m2 = M(host='test2.domain', community='comm')
m2.sysObjectID

returns the expected value:

<Oid: 1.3.6.1.4.1.9.1.1208>

broken on snimpy 0.8.8

m2 = M(host='test2.domain', community='comm')
m2.sysObjectID

fails with:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/myself/.pyenv/versions/venv266/lib/python2.6/site-packages/snimpy/manager.py", line 298, in __getattribute__
    oid, result = self._session.get(a.oid + (0,))[0]
  File "/Users/myself/.pyenv/versions/venv266/lib/python2.6/site-packages/snimpy/snmp.py", line 271, in get
    :return: a list of tuples with the retrieved OID and the raw value.
  File "/Users/myself/.pyenv/versions/venv266/lib/python2.6/site-packages/snimpy/snmp.py", line 263, in _op
    # This seems to be filtered
  File "/Users/myself/.pyenv/versions/venv266/lib/python2.6/site-packages/snimpy/snmp.py", line 221, in _convert
    rfc1902.OctetString: bytes,
  File "/Users/myself/.pyenv/versions/venv266/lib/python2.6/site-packages/pysnmp/smi/rfc1902.py", line 573, in __getattr__
    raise AttributeError(attr)
AttributeError: prettyOut

SNMP sniffing shows correct answer from switch

sudo tcpdump port 161

16:07:07.709666 IP 10.251.5.163.58394 > test2.domain.snmp:  C=comm GetRequest(28)  system.sysObjectID.0
16:07:07.712976 IP test2.domain.snmp > 10.251.5.163.58394:  C=comm GetResponse(37)  system.sysObjectID.0=E:cisco.1.1317

I guess something is not correct, but I do not really understand why the sysOid value get's interpreted as rfc1902.IpAddress in _convert().

I can easily run test code if desired.

@vincentbernat
Copy link
Owner

Thanks for the report. I think this should be easy to fix. I'll try later today.

@vincentbernat
Copy link
Owner

I am unable to reproduce here. Could you give the output of snmpget? I don't know what the E: means in tcpdump.

vincentbernat added a commit that referenced this issue Jan 15, 2016
@cbueche
Copy link
Author

cbueche commented Jan 15, 2016

Here a pair of snmpget:

snmpwalk -v 2c -c comm device SNMPv2-MIB::sysObjectID.0
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.9.1.1208
snmpwalk -On -v 2c -c comm device SNMPv2-MIB::sysObjectID.0
.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.9.1.1208

I think the "E:" means "enterprises".

@vincentbernat
Copy link
Owner

OK, I am able to reproduce this bug on Travis: https://travis-ci.org/vincentbernat/snimpy/jobs/102670039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants