Module: check_mk
Branch: master
Commit: 30e881cd5789688d232e387b7dbea6fdf396af1e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=30e881cd578968…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 24 14:47:49 2018 +0200
Analyze configuration: Fixed wrong results for liveproxyd and persistent connection tests
Previously all analyze configuration tests were executed locally on each
site. In case of the liveproxyd tests and persistent connection tests
this was wrong because the tests have to check the connection
configuration for a specific site on the central site.
The following things have been changed:
* These tests are only triggered on the central sites (see is_relevant()).
* Test results produced on one site can now set the site_id attribute to
the site_id of another site.
These results will not be merged together like it is done for multiple
results affecting a single site.
These results will then be shown in the column of the desired site
instead of the site they were executed on
Change-Id: Ie4a6edf0dfcdd7d5b025f244d1f767b987bbfa62
---
cmk/gui/plugins/wato/ac_tests.py | 24 +++++++++++++++++++-----
cmk/gui/watolib.py | 12 +++++++++++-
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/cmk/gui/plugins/wato/ac_tests.py b/cmk/gui/plugins/wato/ac_tests.py
index 073656f..c1b2bdd 100644
--- a/cmk/gui/plugins/wato/ac_tests.py
+++ b/cmk/gui/plugins/wato/ac_tests.py
@@ -70,12 +70,19 @@ class ACTestPersistentConnections(ACTest):
def is_relevant(self):
- return True
+ # This check is only executed on the central instance of multisite setups
+ return len(config.sitenames()) > 1
def execute(self):
- site_id = config.omd_site()
- site_config = config.site(site_id)
+ for site_id in config.sitenames():
+ site_config = config.site(site_id)
+ for result in self._check_site(site_id, site_config):
+ result.site_id = site_id
+ yield result
+
+
+ def _check_site(self, site_id, site_config):
persist = site_config.get("persist", False)
if persist and watolib.site_is_using_livestatus_proxy(site_id):
@@ -114,11 +121,18 @@ class ACTestLiveproxyd(ACTest):
def is_relevant(self):
- return True
+ # This check is only executed on the central instance of multisite setups
+ return len(config.sitenames()) > 1
def execute(self):
- site_id = config.omd_site()
+ for site_id in config.sitenames():
+ for result in self._check_site(site_id):
+ result.site_id = site_id
+ yield result
+
+
+ def _check_site(self, site_id):
if watolib.site_is_using_livestatus_proxy(site_id):
yield ACResultOK(_("Site is using the Livestatus Proxy Daemon"))
diff --git a/cmk/gui/watolib.py b/cmk/gui/watolib.py
index 2dae2f4..ba7bc89 100644
--- a/cmk/gui/watolib.py
+++ b/cmk/gui/watolib.py
@@ -10029,6 +10029,7 @@ class ACResult(object):
def __init__(self, text):
super(ACResult, self).__init__()
self.text = text
+ self.site_id = config.omd_site()
def from_test(self, test):
@@ -10036,7 +10037,6 @@ class ACResult(object):
self.category = test.category()
self.title = test.title()
self.help = test.help()
- self.site_id = config.omd_site()
@classmethod
@@ -10172,6 +10172,16 @@ class ACTest(object):
def run(self):
self._executed = True
try:
+ # Do not merge results that have been gathered on one site for different
sites
+ results = list(self.execute())
+ num_sites = len(set(r.site_id for r in results))
+ if num_sites > 1:
+ for result in results:
+ result.from_test(self)
+ yield result
+ return
+
+ # Merge multiple results produced for a single site
total_result = ACResult.merge(*list(self.execute()))
total_result.from_test(self)
yield total_result