Module: check_mk
Branch: master
Commit: 2c14e4a2d3b56206d4a6d01faa18d9472e804ae4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2c14e4a2d3b562…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 30 10:15:09 2018 +0200
6186 FIX Fixed crash of Check_MK service on counter wraps in parse functions (e.g.
MKCounterWrapped: WMI query timed out)
When a check raises a MKCounterWrapped exception in the parse function, this check result
should be ignored.
In all 1.5 releases this lead to a crash with an error message like "MKCounterWrapped
(WMI query timed out)"
in case of the WMI checks.
Change-Id: If394764507bbe1056ea59a4be1d9f3e957bc2c48
---
.werks/6186 | 13 +++++++++++++
cmk_base/checking.py | 46 ++++++++++++++++++++++++----------------------
2 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/.werks/6186 b/.werks/6186
new file mode 100644
index 0000000..712f2f8
--- /dev/null
+++ b/.werks/6186
@@ -0,0 +1,13 @@
+Title: Fixed crash of Check_MK service on counter wraps in parse functions (e.g.
MKCounterWrapped: WMI query timed out)
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527667964
+
+When a check raises a MKCounterWrapped exception in the parse function, this check result
should be ignored.
+In all 1.5 releases this lead to a crash with an error message like
"MKCounterWrapped (WMI query timed out)"
+in case of the WMI checks.
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 9982ee7..40eac9c 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -260,36 +260,38 @@ def execute_check(multi_host_sections, hostname, ipaddress,
check_plugin_name, i
section_name = checks.section_name_of(check_plugin_name)
- try:
- section_content = multi_host_sections.get_section_content(hostname,
- ipaddress, section_name,
for_discovery=False)
- except MKParseFunctionError, e:
- x = e.exc_info()
- raise x[0], x[1], x[2] # re-raise the original exception to not destory the
trace
-
# We need to set this again, because get_section_content has the side effect of
setting this with
# item None if there is a parse function. This would break the entire
set_item/get_rate logic
# for checks with items that rely on this being handled by the API.
# TODO: Write a regression test for this.
item_state.set_item_state_prefix(check_plugin_name, item)
- # TODO: Move this to a helper function
- if section_content is None: # No data for this check type
- return False
-
- # In case of SNMP checks but missing agent response, skip this check.
- # Special checks which still need to be called even with empty data
- # may declare this.
- if not section_content and checks.is_snmp_check(check_plugin_name) \
- and not checks.check_info[check_plugin_name]["handle_empty_info"]:
- return False
-
- check_function =
checks.check_info[check_plugin_name].get("check_function")
- if check_function is None:
- check_function = lambda item, params, section_content: (3, 'UNKNOWN - Check
not implemented')
-
dont_submit = False
try:
+ try:
+ section_content = multi_host_sections.get_section_content(hostname,
+ ipaddress, section_name,
for_discovery=False)
+ except MKParseFunctionError, e:
+ x = e.exc_info()
+ # re-raise the original exception to not destory the trace. This may raise a
MKCounterWrapped
+ # exception which need to lead to a skipped check instead of a crash
+ raise x[0], x[1], x[2]
+
+ # TODO: Move this to a helper function
+ if section_content is None: # No data for this check type
+ return False
+
+ # In case of SNMP checks but missing agent response, skip this check.
+ # Special checks which still need to be called even with empty data
+ # may declare this.
+ if not section_content and checks.is_snmp_check(check_plugin_name) \
+ and not checks.check_info[check_plugin_name]["handle_empty_info"]:
+ return False
+
+ check_function =
checks.check_info[check_plugin_name].get("check_function")
+ if check_function is None:
+ check_function = lambda item, params, section_content: (3, 'UNKNOWN -
Check not implemented')
+
# Call the actual check function
item_state.reset_wrapped_counters()