Module: check_mk
Branch: master
Commit: 3e962ea961110ee0b6f60e38e1bcbacc3cf6a98f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3e962ea961110e…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Tue Jun 5 10:05:38 2018 +0200
fix for WK5814. removed in_keepalive_mode helper function in cmk_base.utils
Change-Id: Iabdc68515f39cb6ce5902db41239269035540099
---
cmk_base/checking.py | 16 +++++++++++-----
cmk_base/data_sources/__init__.py | 13 ++++++++++++-
cmk_base/utils.py | 10 ----------
3 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index d177bcb..df93853 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -83,7 +83,7 @@ def handle_check_mk_check_result(check_plugin_name, description):
raise
except MKTimeout:
- if cmk_base.utils.in_keepalive_mode():
+ if _in_keepalive_mode():
raise
else:
infotexts.append("Timed out")
@@ -113,7 +113,7 @@ def handle_check_mk_check_result(check_plugin_name, description):
output_txt = "%s\n%s" % (output_txt,
"\n".join(long_infotexts))
output_txt += "\n"
- if cmk_base.utils.in_keepalive_mode():
+ if _in_keepalive_mode():
keepalive.add_keepalive_active_check_result(hostname, output_txt)
console.verbose(output_txt.encode("utf-8"))
else:
@@ -222,7 +222,7 @@ def _do_all_checks_on_host(sources, hostname, ipaddress,
only_check_plugin_names
filter_mode = "include_clustered"
table = check_table.get_precompiled_check_table(hostname, remove_duplicates=True,
filter_mode=filter_mode,
- world="active" if
cmk_base.utils.in_keepalive_mode() else "config")
+ world="active" if _in_keepalive_mode() else
"config")
# When check types are specified via command line, enforce them. Otherwise use the
# list of checks defined by the check table.
@@ -406,7 +406,7 @@ def _do_status_data_inventory(sources, multi_host_sections, hostname,
ipaddress)
def is_manual_check(hostname, check_plugin_name, item):
manual_checks = check_table.get_check_table(hostname, remove_duplicates=True,
- world="active" if
cmk_base.utils.in_keepalive_mode() else "config",
+ world="active" if _in_keepalive_mode() else
"config",
skip_autochecks=True)
return (check_plugin_name, item) in manual_checks
@@ -599,7 +599,7 @@ def _output_check_result(servicedesc, state, infotext, perftexts):
def _do_submit_to_core(host, service, state, output, cached_at = None, cache_interval =
None):
- if cmk_base.utils.in_keepalive_mode():
+ if _in_keepalive_mode():
# Regular case for the CMC - check helpers are running in keepalive mode
keepalive.add_keepalive_check_result(host, service, state, output, cached_at,
cache_interval)
@@ -712,3 +712,9 @@ def disable_submit():
global _submit_to_core
_submit_to_core = False
+
+def _in_keepalive_mode():
+ if keepalive:
+ return keepalive.enabled()
+ else:
+ return False
diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py
index 87ce1f2..3a03826 100644
--- a/cmk_base/data_sources/__init__.py
+++ b/cmk_base/data_sources/__init__.py
@@ -65,6 +65,17 @@ from .piggyback import PiggyBackDataSource
from .programs import DSProgramDataSource, SpecialAgentDataSource
from .host_sections import HostSections, MultiHostSections
+try:
+ import cmk_base.cee.keepalive as keepalive
+except Exception:
+ keepalive = None
+
+def _in_keepalive_mode():
+ if keepalive:
+ return keepalive.enabled()
+ else:
+ return False
+
# TODO: Cluster with different data sources, eg. TCP node and SNMP node:
# - Discovery works.
# - Checking doesn't work - as it was before. Maybe we can handle this in the
future.
@@ -251,7 +262,7 @@ class DataSources(object):
node_ipaddress = ip_lookup.lookup_ip_address(node_hostname)
table = check_table.get_precompiled_check_table(node_hostname,
remove_duplicates=True, filter_mode="only_clustered",
- world="active"
if cmk_base.utils.in_keepalive_mode() else "config")
+ world="active"
if _in_keepalive_mode() else "config")
node_data_sources = DataSources(node_hostname, node_ipaddress)
node_data_sources.enforce_check_plugin_names(set([e[0] for e in table]))
diff --git a/cmk_base/utils.py b/cmk_base/utils.py
index 5f2096c..751907b 100644
--- a/cmk_base/utils.py
+++ b/cmk_base/utils.py
@@ -43,11 +43,6 @@ from cmk.utils import \
import sys
import itertools
-try:
- import cmk_base.cee.keepalive as keepalive
-except Exception:
- keepalive = None
-
# Aggegates several monitoring states to the worst state
def worst_service_state(*states):
@@ -189,11 +184,6 @@ def has_feature(name):
-def in_keepalive_mode():
- if keepalive:
- return keepalive.enabled()
- else:
- return False
#.
# .--Ctrl-C--------------------------------------------------------------.