Module: check_mk
Branch: master
Commit: 5eafb64b5247bb68c6a22329e232b1cc2ebffae4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5eafb64b5247bb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 7 10:49:39 2017 +0200
5186 FIX Improved error handling when receiving broken SNMP traps
Made it easier to analyze SNMP trap translation issues. By default
only a single line is logged to the mkeventd.log. When you enable
debug logging in the Event Console settings, you'll see more details
about the trap in the mkeventd.log.
Change-Id: Ib03c9ed9614fef3b61747e694d76c282aaa01e2e
---
.werks/5186 | 13 +++++++++++++
bin/mkeventd | 14 +++++++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/.werks/5186 b/.werks/5186
new file mode 100644
index 0000000..ef82032
--- /dev/null
+++ b/.werks/5186
@@ -0,0 +1,13 @@
+Title: Improved error handling when receiving broken SNMP traps
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1504774062
+Class: fix
+
+Made it easier to analyze SNMP trap translation issues. By default
+only a single line is logged to the mkeventd.log. When you enable
+debug logging in the Event Console settings, you'll see more details
+about the trap in the mkeventd.log.
diff --git a/bin/mkeventd b/bin/mkeventd
index 183ad89..e753e84 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -1543,7 +1543,7 @@ class EventServer(object):
# Convert pysnmp datatypes to simply handable ones
- def snmptrap_translate_varbinds(self, var_bind_list):
+ def snmptrap_translate_varbinds(self, ipaddress, var_bind_list):
var_binds = []
if self._mib_resolver is None:
self.logger.warning('Failed to translate OIDs, no modules loaded (see
above)')
@@ -1573,9 +1573,12 @@ class EventServer(object):
var_binds.append((translated_oid, translated_value))
- except SmiError as e:
- # Failed to translate? add untranslated
- self.logger.exception('Failed to translate OID %s: %s' %
(oid.prettyPrint(), e))
+ except (SmiError, ValueConstraintError) as e:
+ self.logger.warning('Failed to translate OID %s (in trap from %s): %s
(enable debug logging for details)' %
+ (oid.prettyPrint(), ipaddress, e))
+ self.logger.debug('Failed trap var binds:\n%s' %
"\n".join([ "%s: %r" % e for e in var_bind_list ]))
+ self.logger.debug(traceback.format_exc())
+
var_binds.append((str(oid), str(value))) # add untranslated
return var_binds
@@ -1597,7 +1600,7 @@ class EventServer(object):
self.log_snmptrap_details(context_engine_id, context_name, var_binds, ipaddress)
if snmptrap_translation_enabled():
- trap = self.snmptrap_translate_varbinds(var_binds)
+ trap = self.snmptrap_translate_varbinds(ipaddress, var_binds)
else:
trap = self.snmptrap_convert_var_binds(var_binds)
@@ -4901,6 +4904,7 @@ try:
from pysnmp.smi.view import MibViewController
from pysnmp.smi.rfc1902 import ObjectType, ObjectIdentity
from pysnmp.smi.error import SmiError
+ from pyasn1.error import ValueConstraintError
if not g_pipe_path:
bail_out("Please specify the path to the pipe (using -P).")