Comments (9)
pip_list.txt
PIP List added.
from pysnmp.
The 1.3.6.1.2.1.1.2.0
OID is in fact part of SNMPv2-MIB
(sysObjectID.0
), do you have it loaded as well?
The other possibility is that you redefine 1.3.6.1.2.1.1.2.0
OID somewhere in your custom MIBs and that OID has a non-OBJECT-TYPE MIB type.
If you enable pysnmp debugging, the whole MIB lookup process should be reported. That might help figuring out the root cause.
from pysnmp.
I attached the Debug log
debug_log.txt
from pysnmp.
It's hard to tell the exact problem without seeing the whole program and relate it to the debug you provided...
Could you please add SNMPv2-MIB
to the load_mib_modules
list (you can drop SNMPv2-SMI
as it's a dependency):
load_mib_modules = "SNMPv2-MIB, <CUSTOM-MIB-1>,<CUSTOM-MIB-2>"
...and re-run your case?
Also, I am not sure how your code is structured, but if you run more than one SNMP query per process invocation, it makes sense (from performance standpoint) to run MIB loading pieces just once.
from pysnmp.
Hi @etingof with SNMPv2-MIB insted of SNMPv2-SMI its working fine.
The structure of code is something like this:
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
oid = (1,3,6,1)
errindication, errstatus, errindex,\
varBindTable = cmdgen.nextCmd(auth_data,
transport,
oid, lexicographicMode=True,
ignoreNonIncreasingOid=True, maxRows=5000,
lookupNames=True, lookupValues=True)
def translate_mib(custom_mib_paths, load_mib_modules, name, val):
if custom_mib_paths and load_mib_modules:
try:
mibBuilder = builder.MibBuilder()
compiler.addMibCompiler(mibBuilder, sources=custom_mib_paths)
mibViewController = view.MibViewController(mibBuilder)
for mibs in load_mib_modules.split(','):
mibBuilder.loadModules(mibs)
except error.MibNotFoundError:
print("Mib Not Found!", "Error")
if custom_mib_paths and load_mib_modules:
output = rfc1902.ObjectType(rfc1902.ObjectIdentity(name), val).resolveWithMib(mibViewController).prettyPrint()
op_list = output.split(" = ")
name = op_list[0].strip()
val = op_list[1].strip()
print('%s = %s' %
(name,
val))
return name, val
else:
print('%s = %s' %
(name.prettyPrint(),
val.prettyPrint()))
return name.prettyPrint(), val.prettyPrint()
custom_mib_paths = "/data/users/MIBS/,/usr/share/snmp/mibs/"
load_mib_modules = "SNMPv2-SMI,<CUSTOM-MIB-1>,<CUSTOM-MIB-2>"
for varBindTableRow in varBindTable:
for name, val in varBindTableRow:
translate_mib(custom_mib_paths, load_mib_modules, name, val)
from pysnmp.
So does that solve you problem or not quite?
I'm not sure why you need the translate_mib()
function at all? It's all seem to be implemented inside pysnmp already. Could you just use ObjectIdentity.addAsn1MibSource and ObjectIdentity.loadMibs instead?
If you still need that custom MIB resolver, I'd strongly recommend making the MibBuilder
and MibViewController
objects initilaized just once rather than inside a loop, as it's currently is.
from pysnmp.
@etingof This solve the problem.
But in my code I have tried the same addAsn1MibSource and .loadMibs when user is providing MIB string(not OID) as a input. which works fine.
But when its with oid for some reason its failing.
>>> ObjectIdentity('1.3.6.1')
ObjectIdentity('1.3.6.1')
>>> ObjectIdentity('1.3.6.1').addAsn1Source('/data/users/sbhattac/MIBS/,/usr/share/snmp/mibs/'.split(','))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sbhattac/VIRT/lib/python2.7/site-packages/pysnmp/smi/rfc1902.py", line 634, in __getattr__
raise SmiError('%s object not properly initialized for accessing %s' % (self.__class__.__name__, attr))
pysnmp.smi.error.SmiError: ObjectIdentity object not properly initialized for accessing addAsn1Source
>>>
>>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').addAsn1Source('http://mibs.snmplabs.com/asn1/@mib@')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sbhattac/VIRT/lib/python2.7/site-packages/pysnmp/smi/rfc1902.py", line 634, in __getattr__
raise SmiError('%s object not properly initialized for accessing %s' % (self.__class__.__name__, attr))
pysnmp.smi.error.SmiError: ObjectIdentity object not properly initialized for accessing addAsn1Source
>>>
Can you please confirm its behavior.
from pysnmp.
That's because you are using the wrong method. It should be .addAsn1MibSource, not .addAsn1Source
.
from pysnmp.
@etingof with addAsn1MibSource its working fine please close it.
Thanks a lot.
from pysnmp.
Related Issues (20)
- SNMPv3 issues with ProCurve device HOT 1
- Latest version of pyasn1 == 0.50 is breaking the pysnmp package. HOT 3
- Sporadic Timeout using set HOT 2
- <lambda>() takes 3 positional arguments but 4 were given HOT 5
- Project URL now redirects to Suspicious/Malware Site HOT 1
- Sending requests from specific interface not working.
- Get no result of getCmd HOT 4
- Attempted "__hash__" operation on ASN.1 schema object HOT 13
- pysnmp doesn't support IPv6 link-local addresses HOT 1
- Hello there, new to python and pysnmp. HOT 2
- AttributeError: 'UdpTransportTarget' object has no attribute 'contextName' HOT 2
- snmpget retry HOT 1
- Some authentication/privacy combinations are not working correctly? HOT 1
- .snmprec Generation HOT 1
- pysnmp usinng with SNMP V3 HOT 3
- Strange error when running the code given HOT 4
- Incomplete OID Retrieval: SNMP Walk (nextCmd/bulkCmd) Fails to Capture All OIDs HOT 6
- This project is dead please open issues with a fork HOT 1
- MibCompiler error when node name is 'as',the key world change to 'pysmi_as'
- Pysnmp HOT 1
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 pysnmp.