Module: check_mk
Branch: master
Commit: 8b711fabd6a0f1ac3a218542567075ff238094c2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b711fabd6a0f1…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Jun 2 11:42:24 2017 +0200
Refactoring: do_all_checks_on_host now returns a dict containing the information from the
check_mk section in its entirety
Change-Id: I48626296e90702a714757926427d04bb320d164b
---
modules/check_mk_base.py | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index bba4dc5..b897813 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1211,9 +1211,11 @@ def do_check(hostname, ipaddress, only_check_types = None):
try:
load_item_state(hostname)
- agent_version, num_success, error_sections, problems = \
+ cmk_section_dict, num_success, error_sections, problems = \
do_all_checks_on_host(hostname, ipaddress, only_check_types)
+ agent_version = cmk_section_dict[u"version"]
+
num_errors = len(error_sections)
save_item_state(hostname)
if problems:
@@ -1503,23 +1505,24 @@ def do_all_checks_on_host(hostname, ipaddress, only_check_types =
None, fetch_ag
submit_aggregated_results(hostname)
if fetch_agent_version:
+ cmk_section_dict = { u"version" : "(unknown)" }
try:
if is_tcp_host(hostname):
- version_info = get_info_for_check(hostname, ipaddress,
'check_mk')
- agent_version = version_info[0][1]
+ for line in get_info_for_check(hostname, ipaddress, 'check_mk'):
+ value = " ".join(line[1:]) if len(line) > 1 else None
+ cmk_section_dict[line[0][:-1].lower()] = value
else:
- agent_version = None
+ cmk_section_dict[u"version"] = None
except MKAgentError:
g_broken_agent_hosts.add(hostname)
- agent_version = "(unknown)"
except:
- agent_version = "(unknown)"
+ pass
else:
- agent_version = None
+ cmk_section_dict[u"version"] = None
error_section_list = sorted(list(error_sections))
- return agent_version, num_success, error_section_list, ", ".join(problems)
+ return cmk_section_dict, num_success, error_section_list, ",
".join(problems)
# Create a crash dump with a backtrace and the agent output.