Module: check_mk
Branch: master
Commit: 0a146f9d268ac01fe01a860a5c37cb67bb749bc2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0a146f9d268ac0…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Apr 26 15:48:59 2018 +0200
5993 FIX Fixed execution of management board checks
This concerns hosts which have configured a management board.
During checking the wrong data source was used and therefore
the wrong data was checked. Fixed that!
Change-Id: If124e1dc01019c3b754d8e0b121a38069028c0f1
---
.werks/5993 | 12 ++++++++++++
cmk_base/checks.py | 11 ++++++++++-
cmk_base/data_sources/abstract.py | 15 ++++++++++++++-
cmk_base/discovery.py | 3 ++-
4 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/.werks/5993 b/.werks/5993
new file mode 100644
index 0000000..0948caa
--- /dev/null
+++ b/.werks/5993
@@ -0,0 +1,12 @@
+Title: Fixed execution of management board checks
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1524749776
+Class: fix
+
+This concerns hosts which have configured a management board.
+During checking the wrong data source was used and therefore
+the wrong data was checked. Fixed that!
diff --git a/cmk_base/checks.py b/cmk_base/checks.py
index 4750b0e..38bedb3 100644
--- a/cmk_base/checks.py
+++ b/cmk_base/checks.py
@@ -765,7 +765,8 @@ def do_status_data_inventory_for(hostname):
return False
-def filter_by_management_board(hostname, found_check_plugin_names, for_mgmt_board):
+def filter_by_management_board(hostname, found_check_plugin_names,
+ for_mgmt_board, for_discovery=False):
# #1 SNMP host with MGMT board
# MGMT board:
# SNMP management board precedence: mgmt_prec_check
@@ -819,6 +820,14 @@ def filter_by_management_board(hostname, found_check_plugin_names,
for_mgmt_boar
if for_mgmt_board:
final_collection.update(mgmt_precedence)
final_collection.update(mgmt_only)
+ if not for_discovery and not config.is_snmp_host(hostname):
+ # Compatibility: in CMK version 1.4.0 if a TCP host has configured
+ # a SNMP management board then SNMP checks (non-"SNMP management
board"-checks)
+ # were discovered. During checking we do not change that behaviour.
+ # Then an upgrade to >=1.5.0 is done.
+ # After a rediscovery the non-"SNMP management board"-checks are
vanished and
+ # "SNMP management board"-checks are discovered.
+ final_collection.update(host_precedence)
else:
final_collection.update(host_precedence)
if not has_mgmt_board:
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index c1f39cb..9959eb0 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -314,11 +314,24 @@ class DataSource(object):
@abc.abstractmethod
def _gather_check_plugin_names(self):
+ """
+ Returns the list of check plugin names which are supported by
+ the device.
+
+ Example: SNMP scan
+ """
raise NotImplementedError()
def enforce_check_plugin_names(self, check_plugin_names):
- self._enforced_check_plugin_names = check_plugin_names
+ """
+ Returns a subset of beforehand gathered check plugin names which are
+ supported by the data source.
+
+ Example: management board checks only for management board data sources
+ """
+ self._enforced_check_plugin_names =
checks.filter_by_management_board(self._hostname,
+ check_plugin_names,
self._for_mgmt_board)
@abc.abstractmethod
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index da640f3..ebc0e5a 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -804,7 +804,8 @@ def snmp_scan(access_data, on_error="ignore", for_inv=False,
do_snmp_scan=True,
if for_inv:
filtered = found_check_plugin_names
else:
- filtered = checks.filter_by_management_board(hostname, found_check_plugin_names,
for_mgmt_board)
+ filtered = checks.filter_by_management_board(hostname, found_check_plugin_names,
+ for_mgmt_board, for_discovery=True)
_output_snmp_check_plugins("SNMP filtered check plugin names", filtered)
snmp.write_single_oid_cache(access_data)
return sorted(filtered)