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

Loading MIB modules one by one to get MIB from OID number #426

Open
mertkanakkoc opened this issue Aug 30, 2022 · 1 comment
Open

Loading MIB modules one by one to get MIB from OID number #426

mertkanakkoc opened this issue Aug 30, 2022 · 1 comment

Comments

@mertkanakkoc
Copy link

Hi,

I try to convert OID numbers to MIB from snmm trap messages. To do that, i created MibBuilder object, gave directories of MIBs using addMibCompiler() and load MIB modules using loadModules(). But to convert OID numbers to MIB in more detail like to get name of a sensor of a device from snmp trap message, giving directories of MIBs is not enough. I had to give MIB module names one by one in loadModules(). But this is not an effective solution, so is there any other method or way for this?

I put an example from the code below:

`from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
from pysnmp.carrier.asyncore.dgram import udp
from pyasn1.codec.ber import decoder
from pysnmp.proto import api
from pysnmp.smi import builder, view, compiler, rfc1902

mibBuilder = builder.MibBuilder()
compiler.addMibCompiler(mibBuilder, sources=['file:///var/lib/mibs/ietf', 'file:///var/lib/mibs/iana'])

mibViewController = view.MibViewController(mibBuilder)
mibBuilder.loadModules('SNMPv2-SMI', 'SNMPv2-TC', 'SNMPv2-MIB', 'RFC1213-MIB', 'IF-MIB')
.
.
.
varBinds = [rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]), x[1]).resolveWithMib(mibViewController) for x
in varBinds]
.
.
.
`

@lextm
Copy link

lextm commented Jan 19, 2023

You should be able to call mibBuilder.loadModules(), simply without specific module names. That forces PySNMP to load as many modules as possible from all sources of MIB documents, so can hurt performance if you put too many MIB documents there but do not actually need to load all of them.

Since you define what is "an effective solution" for yourself, now you know what options provided by this library.

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