Module: check_mk
Branch: master
Commit: 3ebdf3cb6f34ca4edb5b0200c2ca5b73fec8ff1b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3ebdf3cb6f34ca…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 26 08:57:24 2018 +0200
6716 FIX Add SNMP trap processing log target for deep SNMP trap debugging
A new option "SNMP trap processing" has been added to the Event Console log
setting
which tells the underlying SNMP library (PySNMP) to write it's debug output to the
<tt>var/log/mkeventd.log</tt> when set to <tt>Debug</tt>.
Please be careful with this setting. It may result in a lot of log output when you
set it to debug for instances which receive a lot of SNMP traps.
CMK-905
Change-Id: I7d4589434c45edd2b92545b0eb04fdd2eaad00e7
---
.werks/6716 | 27 +++++++++++++++++++++++++++
cmk/ec/.f12 | 2 +-
cmk/ec/main.py | 5 +++--
cmk/ec/snmp.py | 4 ++++
cmk/gui/wato/mkeventd.py | 3 +++
5 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/.werks/6716 b/.werks/6716
new file mode 100644
index 0000000..0f0e7b1
--- /dev/null
+++ b/.werks/6716
@@ -0,0 +1,27 @@
+Title: Add SNMP trap processing log target for deep SNMP trap debugging
+Level: 1
+Component: ec
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1537879295
+
+A new option "SNMP trap processing" has been added to the Event Console log
setting.
+
+This setting is currently used in the following ways:
+
+<ul>
+<li>It controls the log level of all SNMP related log messages. Previously some
+of the SNMP messages were controlled through the "Processing of incoming
+events" setting.</li>
+<li>Nothing is logged in <i>Informational</i> log level</li>
+<li>When set to <i>Verbose</i> it shows details about which traps are
received
+by the Event Console and how they are handled on protocol level (whether they
+are accepted or dropped).</li>
+<li>When set to <i>Debug</i> it tells the underlying SNMP library
(PySNMP) to
+write it's debug output to the <tt>var/log/mkeventd.log</tt>. Please be
careful
+with this level. It may result in a lot of log output when you set it to debug
+for instances which receive a lot of SNMP traps.</li>
+</ul>
diff --git a/cmk/ec/.f12 b/cmk/ec/.f12
index 3384149..662901d 100644
--- a/cmk/ec/.f12
+++ b/cmk/ec/.f12
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
-SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
+SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 464152f..0e37388 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -698,7 +698,7 @@ class EventServer(ECServerThread):
self.open_syslog()
self.open_syslog_tcp()
self.open_snmptrap()
- self._snmp_trap_engine = cmk.ec.snmp.SNMPTrapEngine(self.settings, self._config,
self._logger, self.handle_snmptrap)
+ self._snmp_trap_engine = cmk.ec.snmp.SNMPTrapEngine(self.settings, self._config,
self._logger.getChild("snmp"), self.handle_snmptrap)
self._snmp_trap_translator = cmk.ec.snmp.SNMPTrapTranslator(self.settings,
self._config, self._logger)
@classmethod
@@ -1328,7 +1328,7 @@ class EventServer(ECServerThread):
def reload_configuration(self, config):
self._config = config
- self._snmp_trap_engine = cmk.ec.snmp.SNMPTrapEngine(self.settings, self._config,
self._logger, self.handle_snmptrap)
+ self._snmp_trap_engine = cmk.ec.snmp.SNMPTrapEngine(self.settings, self._config,
self._logger.getChild("snmp"), self.handle_snmptrap)
self._snmp_trap_translator = cmk.ec.snmp.SNMPTrapTranslator(self.settings,
self._config, self._logger)
self.compile_rules(self._config["rules"],
self._config["rule_packs"])
self.host_config.initialize()
@@ -3942,6 +3942,7 @@ def load_configuration(settings, logger, slave_status):
logger.getChild("EventServer").setLevel(levels["cmk.mkeventd.EventServer"])
logger.getChild("EventStatus").setLevel(levels["cmk.mkeventd.EventStatus"])
logger.getChild("StatusServer").setLevel(levels["cmk.mkeventd.StatusServer"])
+
logger.getChild("EventServer.snmp").setLevel(levels["cmk.mkeventd.EventServer.snmp"])
logger.getChild("lock").setLevel(levels["cmk.mkeventd.lock"])
# Are we a replication slave? Parts of the configuration
diff --git a/cmk/ec/snmp.py b/cmk/ec/snmp.py
index d1b5e3b..50d606c 100644
--- a/cmk/ec/snmp.py
+++ b/cmk/ec/snmp.py
@@ -25,6 +25,7 @@
# Boston, MA 02110-1301 USA.
# Needed for receiving traps
+import pysnmp.debug
import pysnmp.entity.config
import pysnmp.entity.engine
import pysnmp.entity.rfc3413.ntfrcv
@@ -57,6 +58,9 @@ class SNMPTrapEngine(object):
self._initialize_snmp_credentials(config)
self._snmp_receiver = SNMPTrapEngine.ECNotificationReceiver(self.snmp_engine,
callback)
+ # Hand over our logger to PySNMP
+ pysnmp.debug.setLogger(pysnmp.debug.Debug("all",
printer=self._logger.debug))
+
@staticmethod
def _auth_proto_for(proto_name):
diff --git a/cmk/gui/wato/mkeventd.py b/cmk/gui/wato/mkeventd.py
index c53de79..62018a7 100644
--- a/cmk/gui/wato/mkeventd.py
+++ b/cmk/gui/wato/mkeventd.py
@@ -3164,6 +3164,9 @@ if mkeventd_enabled:
("cmk.mkeventd.lock", _("Locking"),
_("Log level for the locking mechanics. Setting this to debug will
enable "
"log entries for each lock/unlock action.")),
+ ("cmk.mkeventd.EventServer.snmp", _("SNMP trap
processing"),
+ _("Log level for the SNMP trap processing mechanics. Setting this
to debug will enable "
+ "detailed log entries for each received SNMP trap.")),
]:
elements.append(
(component, DropdownChoice(