Module: check_mk
Branch: master
Commit: 9bc41187eb92e7e5b2223310a92700b934c9a31e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9bc41187eb92e7…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 27 11:37:56 2015 +0200
Implemented check validation to find broken check groups
---
checks/cmctc_lcp | 2 +-
checks/esx_vsphere_counters | 2 +-
checks/icom_repeater | 2 +-
checks/websphere_mq_queues | 2 +-
modules/check_mk.py | 32 ++++++++++++++++++++++++++++++++
5 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/checks/cmctc_lcp b/checks/cmctc_lcp
index b0383bf..28c1b94 100644
--- a/checks/cmctc_lcp
+++ b/checks/cmctc_lcp
@@ -130,7 +130,7 @@ for _s, _i in cmctc_lcp_sensortypes.items():
"check_function" : (lambda st: lambda item,params,info:
check_cmctc_lcp(item, params, info, st))(_s),
"inventory_function" : (lambda st: lambda info:
inventory_cmctc_lcp(info, st))(_s),
"has_perfdata" : True,
- "service_description" : _i[1],
+ "service_description" : _i[1] + " %s",
}
# Set WATO check group for temperature checks
diff --git a/checks/esx_vsphere_counters b/checks/esx_vsphere_counters
index dcc3f85..6cf392e 100644
--- a/checks/esx_vsphere_counters
+++ b/checks/esx_vsphere_counters
@@ -100,7 +100,7 @@ def check_esx_vsphere_counters_diskio(item, params, parsed):
check_info['esx_vsphere_counters.diskio'] = {
'inventory_function' : inventory_esx_vsphere_counters_diskio,
'check_function' : check_esx_vsphere_counters_diskio,
- 'service_description' : 'Disk IO',
+ 'service_description' : 'Disk IO %s',
'has_perfdata' : True,
'group' : 'diskstat',
'includes' : [ "diskstat.include" ],
diff --git a/checks/icom_repeater b/checks/icom_repeater
index f0e0615..baa7b3c 100644
--- a/checks/icom_repeater
+++ b/checks/icom_repeater
@@ -231,7 +231,7 @@ check_info["icom_repeater.temp"] = {
"inventory_function" : inventory_icom_repeater_temp,
"default_levels_variable" :
"icom_repeater_temp_default_levels",
"check_function" : check_icom_repeater_temp,
- "service_description" : "Temperature",
+ "service_description" : "Temperature %s",
"has_perfdata" : True,
"group" : "temperature",
"includes" : [ "temperature.include" ],
diff --git a/checks/websphere_mq_queues b/checks/websphere_mq_queues
index c1a4fa2..4ef4002 100644
--- a/checks/websphere_mq_queues
+++ b/checks/websphere_mq_queues
@@ -70,7 +70,7 @@ check_info["websphere_mq_queues"] = {
"group" : "websphere_mq",
"check_function" : check_websphere_mq_queues,
"inventory_function" : inventory_websphere_mq_queues,
- "service_description" : "MQ Queue",
+ "service_description" : "MQ Queue %s",
"has_perfdata" : True,
}
diff --git a/modules/check_mk.py b/modules/check_mk.py
index be1f312..829fc4b 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -368,6 +368,38 @@ def load_checks():
# Now convert check_info to new format.
convert_check_info()
+ verify_checkgroups()
+
+
+# This function validates the checks which are members of checkgroups to have either
+# all or none an item. Mixed checkgroups lead to strange exceptions when processing
+# the check parameters. So it is much better to catch these errors in a central place
+# with a clear error message.
+def verify_checkgroups():
+ groups = {}
+ for check_type, check in check_info.items():
+ group_name = check["group"]
+ if group_name:
+ groups.setdefault(group_name, [])
+ groups[group_name].append((check_type, check))
+
+ for group_name, checks in groups.items():
+ with_item, without_item = [], []
+ for check_type, check in checks:
+ # Trying to detect whether or not the check has an item. But this mechanism
is not
+ # 100% reliable since Check_MK appends an item to the service_description
when "%s"
+ # is not in the checks service_description template.
+ # Maybe we need to define a new rule which enforces the developer to use the
%s in
+ # the service_description. At least for grouped checks.
+ if "%s" in check["service_description"]:
+ with_item.append(check_type)
+ else:
+ without_item.append(check_type)
+
+ if with_item and without_item:
+ raise MKGeneralException("Checkgroup %s has checks with and without
item! At least one of "
+ "the checks in this group needs to be changed
(With item: %s, "
+ "Without item: %s)" % (group_name, ",
".join(with_item), ", ".join(without_item)))
#.