Comments (12)
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.
mib.get(m, "sysDescr").oid
*** AttributeError: '_cffi_backend.CData' object has no attribute 'encode'
Reviewing my cross-compile environment.
from snimpy.
Sorry, I did give you the wrong command. Try mib.get("SNMPv2-MIB", "sysDescr").oid
.
from snimpy.
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.
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.
>>> 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.
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.
However, as far as I know, smilint
should work exactly the same.
from snimpy.
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.
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.
OK, that's odd that smilint worked without it. Looking at the source code, there is no hard coded path in smilint.
from snimpy.
Used smilint on the desktop. Never used smilint/libsmi on target platforms.
from snimpy.
Related Issues (20)
- Add how to add an new MIB path into the documentation HOT 1
- Windows support HOT 7
- Attribute missing HOT 6
- Trap receiver support HOT 5
- SNMP socket is leaked HOT 5
- Question: How do I lookup values across two tables HOT 9
- How do I get by OID HOT 2
- PMPP support? HOT 4
- snimpy/manager.py broken in Python 3.7
- how do I get an OID from a MIB node ? HOT 5
- How to get KEEPALIVED-MIB::vrrpSyncGroupState HOT 8
- print(mgr.fgVpnTunEntPhase1Name.items()) produces "snimpy.snmp.SNMPNoSuchInstance: No such instance exists" HOT 3
- BGP4-V2-MIB-JUNIPER, take 2
- Use the native Python ipaddress types HOT 4
- SNMP Community Strings greater than 32 characters crash HOT 2
- Confusing example in documentation HOT 1
- Return the pretty name from a referenced OID HOT 5
- Deprecation warning: snimpy not compatible with upcoming Python 3.10 HOT 2
- use unittest.mock instead of mock HOT 1
- Installation snimpy error on AlmaLinux 8.6 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snimpy.