I have been trying to create a trap listener using the PySNMP library, that should load a custom MIB file (already compiled for PySNMP to use with mibdump.py), and print the traps received in a readable format of field name = value.
However, the code is unable to find the MIB files and returns an error:
pysnmp.smi.error.MibNotFoundError: MIB file "BMC-CONTROLMEM-MIB.py[co]" not found in search path (DirMibSource('/home/ign
asi/Workspace/trap-endpoint/.venv/lib/python3.7/site-packages/pysnmp/smi/mibs'),
DirMibSource('/home/ignasi/Workspace/trap-endpoint/.venv/lib/python3.7/site-packages/pysnmp/smi/mibs/instances'),
DirMibSource('/home/ignasi/Workspace/trap-endpo
int/.venv/lib/python3.7/site-packages/pysnmp_mibs'),
DirMibSource('/home/ignasi/.pysnmp/mibs'),
DirMibSource('python_packaged_mibs'),
DirMibSource('/home/ignasi/.pysnmp/mibs'))
I started by following the examples (this), however when I point to my MIB:
for (errorIndication,
errorStatus,
errorIndex,
varBinds) in bulkCmd(SnmpEngine(),
UsmUserData('usr-none-none'),
UdpTransportTarget(('localhost', 5000)),
ContextData(),
0, 50,
ObjectType(
ObjectIdentity('BMC-CONTROLMEM-MIB', 'controlmAlert').addMibSource('/home/ignasi/.pysnmp/mibs').addMibSource('python_packaged_mibs')
),
lexicographicMode=False):
It returns that error.
I have tried to list all paths as explained here and copy the MIB to all folders with no success.
I have also read this post and I do not understand how to generate the MIB in the /instances folder, with the "__" prefix.
Lastly, I do not understand why is searching for a .py[co] file, is it something that must be also compiled?
...modName and modName + "***.py[co]***", ', '.join([str(x) for x in self.__mibSources]))
pysnmp.smi.error.MibNotFoundError: MIB file "BMC-CONTROLMEM-MIB.***py[co]***"
Is there something I missed?
Thanks.