Module: check_mk
Branch: master
Commit: 4fc078d2b5b99fd4af98322e4ca7d5f8245482ee
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4fc078d2b5b99f…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Tue Feb 25 11:47:27 2014 +0100
Rule for checking agents for wanted version
You can now define a rule (in WATO it is called "Check for correct version of
Check_MK agent") to check if the Check_MK Agents have one wanted version.
You may give a version number manually or take the version number of the
monitoring site as a reference.
If the Agent has a different version, the Check_MK service on this host returns
a WARN status, or what ever status you did define in the rule "Status of the
Check_MK service".
---
.werks/702 | 15 +++++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 1 +
modules/check_mk_base.py | 14 ++++++++++++++
web/plugins/wato/check_mk_configuration.py | 17 +++++++++++++++++
5 files changed, 48 insertions(+)
diff --git a/.werks/702 b/.werks/702
new file mode 100644
index 0000000..12c7d3d
--- /dev/null
+++ b/.werks/702
@@ -0,0 +1,15 @@
+Title: Rule for checking agents for wanted version
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1393324817
+Class: feature
+
+You can now define a rule (in WATO it is called "Check for correct version of
+Check_MK agent") to check if the Check_MK Agents have one wanted version.
+You may give a version number manually or take the version number of the
+monitoring site as a reference.
+
+If the Agent has a different version, the Check_MK service on this host returns
+a WARN status, or what ever status you did define in the rule "Status of the
+Check_MK service".
diff --git a/ChangeLog b/ChangeLog
index 6aa1a7c..9c0c30f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
* 0556 esx_vsphere_counters.diskio: now also shows disk latency
* 0583 stulz_pump: now monitors the pumps rpm in precent of maximum and gathers
performance data
* 0560 check_mk_agent.solaris: report statgrab_mem section if solaris_mem section is
missing...
+ * 0702 Rule for checking agents for wanted version...
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index e1844ff..52477f7 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -340,6 +340,7 @@ host_attributes = {} # needed by WATO, ignored by
Check_MK
ping_levels = [] # special parameters for host/PING
check_command
host_check_commands = [] # alternative host check instead of check_icmp
check_mk_exit_status = [] # Rule for specifying CMK's exit status in
case of various errors
+check_mk_agent_target_versions = [] # Rule for defining expected version for
agents
check_periods = []
snmp_check_interval = []
inv_exports = {} # Rulesets for inventory export hooks
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 829f9ed..d0939c1 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -946,6 +946,17 @@ 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
+
# Exit state in various situations is confiugrable since 1.2.3i1
exit_spec = exit_code_spec(hostname)
@@ -963,6 +974,9 @@ 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)
+ 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)
status = exit_spec.get("wrong_version", 1)
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index a378f52..13a7aa0 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -2221,6 +2221,23 @@ register_rule(group,
)
register_rule(group,
+ "check_mk_agent_target_versions",
+ OptionalDropdownChoice(
+ title = _("Check for correct version of Check_MK agent"),
+ help = _("If you want to make sure all of your Check_MK agents are
running"
+ " 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")),
+ ("site", _("Same version as the monitoring site")),
+ ],
+ otherlabel = _("Custom ->"),
+ explicit = TextAscii(allow_empty = False),
+ default_value = "ignore",
+ )
+)
+
+register_rule(group,
"piggyback_translation",
HostnameTranslation(
title = _("Hostname translation for piggybacked hosts"),