Module: check_mk
Branch: master
Commit: 5e6943546d948be79d760c851c67aef39956e288
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5e6943546d948b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 22 09:23:15 2017 +0100
Analyze config: Aggregate multiple test results together to one for each test per site
Change-Id: I71040203b63a8e2573b32e8caa0ffefda43ba7e8
---
web/htdocs/watolib.py | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 9fe61e0..9aebf8f 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -9449,6 +9449,26 @@ class ACResult(object):
self.site_id = config.omd_site()
+ @classmethod
+ def merge(cls, *results):
+ """Create a new result object from the given result objects.
+
+ a) use the worst state
+ b) concatenate the texts
+ """
+ texts, worst_cls = [], ACResultOK
+ for result in results:
+ text = result.text
+ if result.status != 0:
+ text += " (%s)" % ("!"*result.status)
+ texts.append(text)
+
+ if result.status > worst_cls.status:
+ worst_cls = result.__class__
+
+ return worst_cls(", ".join(texts))
+
+
def status_name(self):
return cmk.defines.short_service_state_name(self.status)
@@ -9552,9 +9572,9 @@ class ACTest(object):
def run(self):
self._executed = True
try:
- for result in self.execute():
- result.from_test(self)
- yield result
+ total_result = ACResult.merge(*list(self.execute()))
+ total_result.from_test(self)
+ yield total_result
except Exception, e:
log_exception()
result = ACResultCRIT("<pre>%s</pre>" %