Module: check_mk
Branch: master
Commit: bed81e57c162d8420b3cf3df8badc0fa0c3de0b7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bed81e57c162d8…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jan 16 13:21:25 2018 +0100
5618 FIX skype.sip_stack: Fixed "missing key" error which caused a check crash
Above error was a result of different key notations for
the same object, eg. in "skype.sip_stack" we got
- "SIP - Incoming Responses Dropped /Sec" and
- "SIP - Incoming Responses Dropped/sec"
Now we normalize these keys by ignoring upper/lower
case and spaces.
Change-Id: I8a80f590154da1c59a65e66f728036ac0d19c959
---
.werks/5618 | 15 +++++++++++++++
checks/wmi.include | 15 +++++++++++++--
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/.werks/5618 b/.werks/5618
new file mode 100644
index 0000000..1e84f4e
--- /dev/null
+++ b/.werks/5618
@@ -0,0 +1,15 @@
+Title: skype.sip_stack: Fixed "missing key" error which caused a check crash
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1516097649
+Class: fix
+
+Above error was a result of different key notations for
+the same object, eg. in "skype.sip_stack" we got
+- "SIP - Incoming Responses Dropped /Sec" and
+- "SIP - Incoming Responses Dropped/sec"
+Now we normalize these keys by ignoring upper/lower
+case and spaces.
diff --git a/checks/wmi.include b/checks/wmi.include
index bdc7703..45f3e11 100644
--- a/checks/wmi.include
+++ b/checks/wmi.include
@@ -74,13 +74,14 @@ def parse_wmi_table(info, key="Name"):
# MS apparently doesn't bother to provide a name
# for base columns with performance counters
header = prev_header + "_Base"
+ header = self._normalize_key(header)
self.__headers[header] = index
prev_header = header
index += 1
self.__key_index = None
if key_field is not None:
try:
- self.__key_index = self.__headers[key_field]
+ self.__key_index = self.__headers[self._normalize_key(key_field)]
except KeyError, e:
raise KeyError(e.message + " missing, valid keys: "
+ ", ".join(self.__headers.keys()))
@@ -114,7 +115,7 @@ def parse_wmi_table(info, key="Name"):
col_index = column
else:
try:
- col_index = self.__headers[column]
+ col_index = self.__headers[self._normalize_key(column)]
except KeyError, e:
raise MKGeneralException(e.message + " missing, valid keys:
"
+ ", ".join(self.__headers.keys()))
@@ -136,6 +137,16 @@ def parse_wmi_table(info, key="Name"):
def frequency(self):
return self.__frequency
+ def _normalize_key(self, key):
+ # Different API versions may return different headers/keys
+ # for equal objects, eg. "skype.sip_stack":
+ # - "SIP - Incoming Responses Dropped /Sec"
+ # - "SIP - Incoming Responses Dropped/sec"
+ # For these cases we normalize these keys to be independent of
+ # upper/lower case and spaces.
+ return key.replace(" ", "").lower()
+
+
try:
info_iter = iter(info)
res = None