Module: check_mk
Branch: master
Commit: 89337fce5980a4a15f55f13fcc3b2f57a170b5a0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=89337fce5980a4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 24 09:36:49 2016 +0100
4069 FIX cmciii.phase: Fixed broken check with some devices
The check failed to discover services on devices not reporting a
"device" info in the phase name.
The check also failed for devices having spaces in the unit names.
---
.werks/4069 | 13 +++++++++++++
ChangeLog | 1 +
checks/cmciii | 31 +++++++++++++++++++++++++------
3 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/.werks/4069 b/.werks/4069
new file mode 100644
index 0000000..66269ee
--- /dev/null
+++ b/.werks/4069
@@ -0,0 +1,13 @@
+Title: cmciii.phase: Fixed broken check with some devices
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1479976504
+
+The check failed to discover services on devices not reporting a
+"device" info in the phase name.
+
+The check also failed for devices having spaces in the unit names.
diff --git a/ChangeLog b/ChangeLog
index a186e1f..e38b932 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
* 4088 FIX: ntp: fixed incomplete data handling
* 4090 FIX: apc_rackpdu_power, apc_symmetra, apc_symmetra_input, apc_symmetra_output:
some fixes...
* 4091 FIX: oracle_tablespace: Werk 3907 broke the detection of UNDO- and
TEMP-Tablespaces
+ * 4069 FIX: cmciii.phase: Fixed broken check with some devices...
Multisite:
* 3974 FIX: Sorting comments in hover menu of comments icon by time now
diff --git a/checks/cmciii b/checks/cmciii
index 5300a88..5f0cb34 100644
--- a/checks/cmciii
+++ b/checks/cmciii
@@ -856,8 +856,15 @@ def reparse_cmciii_phase(parsed):
for name, value in inputs.items():
if name[1].find("Phase") != -1:
parts = name[1].split('.')
+
+ # Prepend an empty device name to handle the special case where
+ # no device name is given in the alias
+ if name[1].startswith("Phase "):
+ parts = [""] + parts
+
if len(parts) == 3:
device, phase, value_name = parts
+
else:
device, phase, value_name, value_name_add = parts
value_name = (value_name, value_name_add)
@@ -866,23 +873,35 @@ def reparse_cmciii_phase(parsed):
unit = units[unit_id-1][1]
phase = phase[-1]
+ # Device may contain spaces. Replace them because spaces will break
+ # item matching in the check.
+ device = device.replace(" ", "_")
+
output.setdefault((unit, device, phase), {})
output[(unit, device, phase)][value_name] = value
-
-
return output
def inventory_cmciii_phase(parsed):
parsed = reparse_cmciii_phase(parsed)
- for device, unit, phase in parsed.keys():
- yield "%s %s Phase %s" % (device, unit, phase), {}
+ for unit, device, phase in parsed.keys():
+ if device:
+ item = "%s %s Phase %s" % (unit, device, phase)
+ else:
+ item = "%s Phase %s" % (unit, phase)
+
+ yield item, {}
def check_cmciii_phase(item, params, parsed):
- device, unit, word, phase = item.split()
- data = reparse_cmciii_phase(parsed)[(device, unit, phase)]
+ item_parts = item.split()
+ if len(item_parts) == 3:
+ unit, device, phase = item_parts[0], "", item_parts[-1]
+ else:
+ unit, device, _unused, phase = item_parts
+
+ data = reparse_cmciii_phase(parsed)[(unit, device, phase)]
parsed = {}
parsed[item] = {}