Module: check_mk
Branch: master
Commit: 84524a4e5d6ce8cd836d68dc6e408db0995b1c62
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=84524a4e5d6ce8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Feb 26 15:36:14 2014 +0100
FIX: fix new agent version check with precompiled checks
Check_MK with precompiled host checks (using Nagios core) would
completely fail otherwise
---
modules/check_mk.py | 13 +++++++++++++
modules/check_mk_base.py | 15 +++------------
web/plugins/wato/check_mk_configuration.py | 4 ++--
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 6b05bf8..12a5a98 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -642,6 +642,16 @@ def check_interval_of(hostname, checkname):
if match is None or match == checkname:
return minutes # use first match
+def agent_target_version(hostname):
+ agent_target_versions = host_extra_conf(hostname, check_mk_agent_target_versions)
+ if len(agent_target_versions) > 0:
+ if agent_target_versions[0] == "ignore":
+ return None
+ elif agent_target_versions[0] == "site":
+ return check_mk_version
+ else:
+ return agent_target_versions[0]
+
#.
# .--SNMP----------------------------------------------------------------.
# | ____ _ _ __ __ ____ |
@@ -3404,6 +3414,9 @@ no_inventory_possible = None
# Piggyback translations
output.write("def get_piggyback_translation(hostname):\n return %r\n\n"
% get_piggyback_translation(hostname))
+ # Expected agent version
+ output.write("def agent_target_version(hostname):\n return %r\n\n" %
agent_target_version(hostname))
+
# SNMP character encoding
output.write("def get_snmp_character_encoding(hostname):\n return
%r\n\n"
% get_snmp_character_encoding(hostname))
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index d0939c1..1f502e3 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -946,16 +946,7 @@ def do_check(hostname, ipaddress, only_check_types = None):
start_time = time.time()
- agent_target_versions = host_extra_conf(hostname, check_mk_agent_target_versions)
- if len(agent_target_versions) > 0:
- if agent_target_versions[0] == "ignore":
- check_mk_agent_target_version = None
- elif agent_target_versions[0] == "site":
- check_mk_agent_target_version = check_mk_version
- else:
- check_mk_agent_target_version = agent_target_versions[0]
- else:
- check_mk_agent_target_version = None
+ expected_version = agent_target_version(hostname)
# Exit state in various situations is confiugrable since 1.2.3i1
exit_spec = exit_code_spec(hostname)
@@ -974,8 +965,8 @@ def do_check(hostname, ipaddress, only_check_types = None):
elif num_errors > 0:
output = "Got no information from host, "
status = exit_spec.get("empty_output", 2)
- elif check_mk_agent_target_version and agent_version !=
check_mk_agent_target_version:
- output = "different agent version %s (should be %s), " %
(agent_version, check_mk_agent_target_version)
+ elif expected_version and agent_version != expected_version:
+ output = "unexpected agent version %s (should be %s), " %
(agent_version, expected_version)
status = exit_spec.get("wrong_version", 1)
elif agent_min_version and agent_version < agent_min_version:
output = "old plugin version %s (should be at least %s), " %
(agent_version, agent_min_version)
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 13a7aa0..2f6faf7 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -2228,10 +2228,10 @@ register_rule(group,
" one specific version, you may set it by this rule. Agents running
"
" some different version return a none ok state then"),
choices = [
- ("ignore", _("Ignore version")),
+ ("ignore", _("Ignore the version")),
("site", _("Same version as the monitoring site")),
],
- otherlabel = _("Custom ->"),
+ otherlabel = _("Specific version"),
explicit = TextAscii(allow_empty = False),
default_value = "ignore",
)