Giter VIP home page Giter VIP logo

Comments (12)

vincentbernat avatar vincentbernat commented on May 22, 2024

Could you bypass the check and check the OID you get with mib.get(m, "sysDescr").oid?

If the OID is quite incorrect, I suspect that CFFI didn't understand your target during cross-compilation.

from snimpy.

midicase avatar midicase commented on May 22, 2024

mib.get(m, "sysDescr").oid

*** AttributeError: '_cffi_backend.CData' object has no attribute 'encode'

Reviewing my cross-compile environment.

from snimpy.

vincentbernat avatar vincentbernat commented on May 22, 2024

Sorry, I did give you the wrong command. Try mib.get("SNMPv2-MIB", "sysDescr").oid.

from snimpy.

midicase avatar midicase commented on May 22, 2024

Can I run that like this? Changed the conformace test to "< 1" so 1 passes:

>>> from snimpy import mib
>>> oid = mib.get("/usr/share/snmp/mibs/SNMPv2-MIB", "sysDescr").oid
>>> print oid
(0L, 1L, 1L)

from snimpy.

vincentbernat avatar vincentbernat commented on May 22, 2024

You can try snimpy 0.6.4. It still uses libsmi but it uses a classic Python module instead of CFFI. If it works, the problem is likely with CFFI. I would have expected the OID to be something with very high numbers or that you would get segfaults.

Could you try:

import snimpy.mib
from snimpy.smi import smi, ffi
a=smi.smiGetModule("SNMPv2-MIB")
print ffi.string(a.name)
c=smi.smiGetNode(a, "sysDescr")
print ffi.string(c.name)
print c.oidlen
print [x for x in c.oid[0:c.oidlen]]

from snimpy.

midicase avatar midicase commented on May 22, 2024
>>> import snimpy.mib
>>> from snimpy.smi import smi, ffi
>>> a=smi.smiGetModule("/usr/share/snmp/mibs/SNMPv2-MIB")
>>> print ffi.string(a.name)
SNMPv2-MIB
>>> c=smi.smiGetNode(a, "sysDescr")
>>> print ffi.string(c.name)
sysDescr
>>> print c.oidlen
3
>>> print [x for x in c.oid[0:c.oidlen]]
[0L, 1L, 1L]

I noticed that I have to put the fully qualified path to load, but since some mibs have IMPORTS, how does snimpy (or rather libsmi) resolve?

I tried running in the mibs directory
[root@t21 mibs]# pwd
/usr/share/snmp/mibs
[root@t21 mibs]# python

Python 2.7.3 (default, Feb  1 2015, 04:34:21) 
[GCC 4.7.3 20121106 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import snimpy.mib
>>> from snimpy.smi import smi, ffi
>>> a=smi.smiGetModule("SNMPv2-MIB")
>>> print ffi.string(a.name)
Segmentation fault

from snimpy.

vincentbernat avatar vincentbernat commented on May 22, 2024

Oh, yes, maybe libsmi is not configured correctly. It reads a configuration file (/etc/smi.conf for example). There is a default search path and you can add more in /etc/smi.conf. You could add:

path :/usr/share/snmp/mibs

For loading dependencies, libsmi will try to load them automatically.

from snimpy.

vincentbernat avatar vincentbernat commented on May 22, 2024

However, as far as I know, smilint should work exactly the same.

from snimpy.

vincentbernat avatar vincentbernat commented on May 22, 2024

If it helps, I have just pushed a commit that should display the error that libsmi detected. For example:

SMIException: /home/bernat/Documents/Deezer/MIB/allied/ATSWTCH2-MIB contains major SMI error (/home/bernat/Documents/Deezer/MIB/allied/ATSWTCH2-MIB:47: failed to locate MIB module `RFC-1212': check with smilint -s -l1)

from snimpy.

midicase avatar midicase commented on May 22, 2024
path :/usr/share/snmp/mibs

smi.conf is the fix. Thank you! I feel bad since it was not an issue with snimpy. libsmi does not include or install an smi.conf. Distro handlers seem to be manually doing it. I'll add it to buildroot.

>>> from snimpy.manager import Manager as M
>>> from snimpy.manager import load
>>> load("SNMPv2-MIB")
>>> m = M("localhost", "public", 2)
>>> print(m.sysDescr)
Linux t21 3.10.12 #1 SMP Thu Oct 23 11:15:42 EDT 2014 armv7l

from snimpy.

vincentbernat avatar vincentbernat commented on May 22, 2024

OK, that's odd that smilint worked without it. Looking at the source code, there is no hard coded path in smilint.

from snimpy.

midicase avatar midicase commented on May 22, 2024

Used smilint on the desktop. Never used smilint/libsmi on target platforms.

from snimpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.