Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
fix: partial fix for dynamic MIB loading
Browse files Browse the repository at this point in the history
- fixed to lazy load extra MIBs only when the exception is a non-OBJECT-TYPE exception
  • Loading branch information
lingy1028 committed Jul 20, 2021
1 parent d17cfc5 commit 3d6e791
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions splunk_connect_for_snmp_mib_server/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,23 @@ def mib_translator(self, var_bind):
rfc1902.ObjectIdentity(name), val
).resolveWithMib(self._mib_view_controller)
except Exception as e:
logger.error(f"Error happened in translation: {e} trying to lazy load MIBs")
self.find_mib_file(name)
try:
translated_var_bind = rfc1902.ObjectType(
rfc1902.ObjectIdentity(name), val
).resolveWithMib(self._mib_view_controller)
logger.debug(
f"* Re-Translated PDU: {translated_var_bind.prettyPrint()}"
)
logger.error(f"Error happened in translation: {e}")
if "not OBJECT-TYPE" in str(e):
logger.info("[-] Trying to lazy load MIBs")
self.find_mib_file(name)
try:
translated_var_bind = rfc1902.ObjectType(
rfc1902.ObjectIdentity(name), val
).resolveWithMib(self._mib_view_controller)
logger.debug(
f"* Re-Translated PDU: {translated_var_bind.prettyPrint()}"
)
return translated_var_bind.prettyPrint().replace(" = ", "=")

except Exception as e:
logger.debug(f"Error happened during translation checking: {e}")
except Exception as e:
logger.debug(f"Error happened during translation checking: {e}")
return None
else:
return None

return translated_var_bind.prettyPrint().replace(" = ", "=")
Expand Down

0 comments on commit 3d6e791

Please sign in to comment.