Module: check_mk
Branch: master
Commit: 1b7f4f9768e0119fd2261e07034275bc60d7834e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1b7f4f9768e011…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Dec 15 16:17:37 2017 +0100
5416 FIX Prevent MS Exchange checks from crashing upon WMI timeout
Werk #5411 introduced the identification and handling of WMI timeouts.
Some of nested subsections, at least those of MS Exchange, may under
certain circumstances produce an unprecedented order of output lines
suddenly ending in a WMI timeout. This scenario was not expected when
preparing #5411, causing the parsing of some MS Exchange subsections
to fail and the corresponding check to crash.
This fix ensures that a WMI timeout is properly parsed regardless of
where it appears in a subsection output. The corresponding checks no
longer crash but issue a PENDING/UNKNOWN result.
Change-Id: Ic43050a153a1dcb05286564d4a5478934b74fdd4
---
.werks/5416 | 19 +++++++++++++++++++
checks/wmi.include | 19 ++++++++++++-------
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/.werks/5416 b/.werks/5416
new file mode 100644
index 0000000..7b579e1
--- /dev/null
+++ b/.werks/5416
@@ -0,0 +1,19 @@
+Title: Prevent MS Exchange checks from crashing upon WMI timeout
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1513609941
+Class: fix
+
+Werk #5411 introduced the identification and handling of WMI timeouts.
+Some of nested subsections, at least those of MS Exchange, may under
+certain circumstances produce an unprecedented order of output lines
+suddenly ending in a WMI timeout. This scenario was not expected when
+preparing #5411, causing the parsing of some MS Exchange subsections
+to fail and the corresponding check to crash.
+
+This fix ensures that a WMI timeout is properly parsed regardless of
+where it appears in a subsection output. The corresponding checks no
+longer crash but issue a PENDING/UNKNOWN result.
diff --git a/checks/wmi.include b/checks/wmi.include
index 5d88176..bdc7703 100644
--- a/checks/wmi.include
+++ b/checks/wmi.include
@@ -147,10 +147,11 @@ def parse_wmi_table(info, key="Name"):
timestamp = int(line[1])
frequency = int(line[2])
line = info_iter.next()
- elif line[0] == "WMItimeout":
- # main section got WMI timeout
- raise MKCounterWrapped("WMI query timed out")
+ else:
+ # Did main section get WMI timeout?
+ check_wmi_timeout(line)
while line is not None:
+ check_wmi_timeout(line)
current = None
if len(line) == 1 and line[0].startswith("["):
# multi-table input
@@ -158,9 +159,8 @@ def parse_wmi_table(info, key="Name"):
res = {}
tablename = regex("\[(.*)\]").search(line[0]).group(1)
line = info_iter.next()
- if line[0] == "WMItimeout":
- # subsection got WMI timeout
- raise MKCounterWrapped("WMI query timed out")
+ # Did subsection get WMI timeout?
+ check_wmi_timeout(line)
if tablename in res:
# known table, append to it
current = res[tablename]
@@ -175,9 +175,9 @@ def parse_wmi_table(info, key="Name"):
# read table content
line = info_iter.next()
while line is not None and not line[0].startswith("["):
+ check_wmi_timeout(line)
current.add_row(line)
line = info_iter.next()
-
except StopIteration:
# regular end of block
pass
@@ -185,6 +185,11 @@ def parse_wmi_table(info, key="Name"):
return res
+def check_wmi_timeout(line):
+ if line[0] == "WMItimeout":
+ raise MKCounterWrapped("WMI query timed out")
+
+
#.
# .--Filters-------------------------------------------------------------.
# | _____ _ _ _ |