Module: check_mk
Branch: master
Commit: bd52fca00075284bb6616c0bee784ce26bb778cb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bd52fca0007528…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 17 09:10:54 2018 +0100
5650 FIX Fixed service discovery page for SNMP cluster hosts
The service discovery page of WATO was showing a warning message
and no discovery could be performed for this host using the GUI
anymore.
Change-Id: I8f696b32d8941ad3b4ea7d2d9367c591121001e6
Workaround: Use the discovery mode on the command line via <tt>cmk -II
[HOSTNAME]</tt>.
---
.werks/5650 | 15 +++++++++++++++
cmk_base/data_sources/__init__.py | 10 ++++++++++
cmk_base/data_sources/snmp.py | 4 ++++
cmk_base/discovery.py | 17 ++++++++++++++---
4 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/.werks/5650 b/.werks/5650
new file mode 100644
index 0000000..90423fa
--- /dev/null
+++ b/.werks/5650
@@ -0,0 +1,15 @@
+Title: Fixed service discovery page for SNMP cluster hosts
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1516176294
+Class: fix
+
+The service discovery page of WATO was showing a warning message
+"Service discovery failed for this host: The check type filter function has not been
set "
+and no discovery could be performed for this host using the GUI
+anymore.
+
+Workaround: Use the discovery mode on the command line via <tt>cmk -II
[HOSTNAME]</tt>.
diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py
index b48eeaf..0cc0b04 100644
--- a/cmk_base/data_sources/__init__.py
+++ b/cmk_base/data_sources/__init__.py
@@ -85,6 +85,10 @@ class DataSources(object):
self._hostname = hostname
self._initialize_data_sources()
+ # Has currently no effect. The value possibly set during execution on the single
data
+ # sources is kept here in this object to return it later on
+ self._enforced_check_plugin_names = None
+
def _initialize_data_sources(self):
self._sources = {}
@@ -202,10 +206,16 @@ class DataSources(object):
def enforce_check_plugin_names(self, check_plugin_names):
+ self._enforced_check_plugin_names = check_plugin_names
for source in self.get_data_sources():
source.enforce_check_plugin_names(check_plugin_names)
+ def get_enforced_check_plugin_names(self):
+ """Returns either the collection of enforced check plugin names
(when they have been set before) or None"""
+ return self._enforced_check_plugin_names
+
+
def get_data_sources(self):
# Always execute piggyback at the end
return sorted(self._sources.values(), key=lambda s: (isinstance(s,
PiggyBackDataSource), s.id()))
diff --git a/cmk_base/data_sources/snmp.py b/cmk_base/data_sources/snmp.py
index ae41c07..2b539e8 100644
--- a/cmk_base/data_sources/snmp.py
+++ b/cmk_base/data_sources/snmp.py
@@ -126,6 +126,10 @@ class SNMPDataSource(DataSource):
self._do_snmp_scan = do_snmp_scan
+ def get_do_snmp_scan(self):
+ return self._do_snmp_scan
+
+
def set_check_plugin_name_filter(self, filter_func):
self._check_plugin_name_filter_func = filter_func
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index 3709a35..4b97d41 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -111,13 +111,13 @@ def do_discovery(hostnames, check_plugin_names, only_new):
ipaddress = ip_lookup.lookup_ip_address(hostname)
- sources = _get_sources_for_discovery(hostname, check_plugin_names,
do_snmp_scan, on_error)
-
# Usually we disable SNMP scan if cmk -I is used without a list of
# explicity hosts. But for host that have never been service-discovered
# yet (do not have autochecks), we enable SNMP scan.
do_snmp_scan = not use_caches or not _has_autochecks(hostname)
+ sources = _get_sources_for_discovery(hostname, check_plugin_names,
do_snmp_scan, on_error)
+
multi_host_sections = _get_host_sections_for_discovery(sources, hostname,
ipaddress,
use_caches=use_caches)
@@ -1128,11 +1128,22 @@ def _merge_manual_services(services, hostname, on_error):
def _get_cluster_services(hostname, ipaddress, sources, multi_host_sections, on_error):
nodes = config.nodes_of(hostname)
+ # Get setting from cluster SNMP data source
+ do_snmp_scan = False
+ for source in sources.get_data_sources():
+ if isinstance(source, data_sources.SNMPDataSource):
+ do_snmp_scan = source.get_do_snmp_scan()
+
# Get services of the nodes. We are only interested in "old",
"new" and "vanished"
# From the states and parameters of these we construct the final state per service.
cluster_items = {}
for node in nodes:
- node_sources = _get_sources_for_discovery(node, check_plugin_names, do_snmp_scan,
on_error)
+ node_sources = _get_sources_for_discovery(node,
+ check_plugin_names=sources.get_enforced_check_plugin_names(),
+ do_snmp_scan=do_snmp_scan,
+ on_error=on_error,
+ )
+
node_ipaddress = ip_lookup.lookup_ip_address(node)
services = _get_discovered_services(node, node_ipaddress, node_sources,
multi_host_sections, on_error)
for (check_plugin_name, item), (check_source, paramstring) in services.items():