Module: check_mk
Branch: master
Commit: 2b1234362c69e7261bd9e7f86ad06f6bf44c6440
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b1234362c69e7…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Aug 1 10:51:01 2018 +0200
Check_MK service: The configured overall status was ignored
Change-Id: I98462878ccd86d262c988714430927c79209fdc9
---
cmk_base/config.py | 18 +++++++++++++++++-
cmk_base/data_sources/abstract.py | 22 +---------------------
2 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/cmk_base/config.py b/cmk_base/config.py
index be96928..afb72f7 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -1132,11 +1132,27 @@ def contactgroups_of(hostname):
# Misc
#
-def exit_code_spec(hostname):
+def exit_code_spec(hostname, data_source_id=None):
spec = {}
specs = host_extra_conf(hostname, check_mk_exit_status)
for entry in specs[::-1]:
spec.update(entry)
+ return _get_exit_code_spec(spec, data_source_id)
+
+
+def _get_exit_code_spec(spec, data_source_id):
+ if data_source_id is not None:
+ try:
+ return spec["individual"][data_source_id]
+ except KeyError:
+ pass
+
+ try:
+ return spec["overall"]
+ except KeyError:
+ pass
+
+ # Old configuration format
return spec
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index c63551b..11b3089 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -84,7 +84,7 @@ class DataSource(object):
# Runtime data (managed by self.run()) - Meant for self.get_summary_result()
self._exception = None
self._host_sections = None
- self._exit_code_spec = self._get_exit_code_spec()
+ self._exit_code_spec = config.exit_code_spec(hostname, data_source_id=self.id())
def _setup_logger(self):
@@ -94,26 +94,6 @@ class DataSource(object):
(tty.bold, tty.normal, self.id(), tty.bold, tty.normal))
- def _get_exit_code_spec(self):
- exit_code_spec = config.exit_code_spec(self._hostname)
- try:
- return self._get_individual_exit_code_spec(exit_code_spec)
- except KeyError:
- pass
-
- try:
- return exit_code_spec["overall"]
- except KeyError:
- pass
-
- # Old configuration format
- return exit_code_spec
-
-
- def _get_individual_exit_code_spec(self, exit_code_spec):
- return exit_code_spec["individual"][self.id()]
-
-
def run(self, hostname=None, ipaddress=None, get_raw_data=False):
"""Wrapper for self._execute() that unifies several things: