Module: check_mk
Branch: master
Commit: f03c3e9a45e7e60ab7365dbb26e533edbce62072
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f03c3e9a45e7e6…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Wed Feb 22 12:19:37 2017 +0100
4196 FIX blade_blades: fixed out of range state
The check will not crash anymore if a state reported by a bladecenter is
our of range. Instead the failed part of this service will change to UNKNOWN.
Change-Id: I08cc571af1c06f0c4741f0230431e262bd0bd85c
---
.werks/4196 | 10 ++++++
checks/blade_blades | 94 ++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 78 insertions(+), 26 deletions(-)
diff --git a/.werks/4196 b/.werks/4196
new file mode 100644
index 0000000..d224b82
--- /dev/null
+++ b/.werks/4196
@@ -0,0 +1,10 @@
+Title: blade_blades: fixed out of range state
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.5.0i1
+Date: 1487762152
+Class: fix
+
+The check will not crash anymore if a state reported by a bladecenter is
+our of range. Instead the failed part of this service will change to UNKNOWN.
diff --git a/checks/blade_blades b/checks/blade_blades
index 7eb4965..5d8540f 100644
--- a/checks/blade_blades
+++ b/checks/blade_blades
@@ -24,45 +24,87 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2.1 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2.2 2
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2.3 3
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2.4 4
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.2.5 5
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3.1 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3.2 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3.3 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3.4 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.3.5 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4.1 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4.2 3
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4.3 255
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4.4 0
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.4.5 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.5.1 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.5.2 12
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.5.3 9
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.5.4 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.5.5 1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.6.1 ESX1
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.6.2 ESX109
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.6.3 ESX110
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.6.4 ESX137
+#.1.3.6.1.4.1.2.3.51.2.22.1.5.1.1.6.5 ESX138
+
-def parse_blade_blades(info):
- map_states = {
- 'exist_state' : ((2, "no"), (0, "yes")),
- 'power_state' : ((1, "off"), (0, "on")),
- 'health_state' : ((3, "unknown"), (0, "good"), (1,
"warning"), (2, "bad")),
- }
- parsed = {}
+def inventory_blade_blades(info):
for line in info:
- parsed[line[0]] = [
- map_states['exist_state'][int(line[1])],
- map_states['power_state'][int(line[2])],
- map_states['health_state'][int(line[3])],
- line[4]
- ]
+ if line[2] == '1':
+ yield (line[0], None)
+
+
+def check_blade_blades(item, _no_params, info):
+ map_exists = {
+ '0' : (2, "false"),
+ '1' : (0, "true")
+ }
- return parsed
+ map_power = {
+ '0' : (2, "off"),
+ '1' : (0, "on"),
+ '3' : (1, "standby"),
+ '4' : (1, "hibernate"),
+ '255' : (3, "unknown"),
+ }
-def inventory_blade_blades(parsed):
- for key, value in parsed.iteritems():
- if not parsed[key][1][1] == "off": # Only inventory powered on blades
- yield (key, None)
+ map_health = {
+ '0' : (3, "unknown"),
+ '1' : (0, "good"),
+ '2' : (1, "warning"),
+ '3' : (2, "critical"),
+ '4' : (1, "kernel mode"),
+ '5' : (0, "discovering"),
+ '6' : (2, "communications error"),
+ '7' : (2, "no power"),
+ '8' : (1, "flashing"),
+ '9' : (2, "initialization Failure"),
+ '10' : (2, "insuffiecient power"),
+ '11' : (2, "power denied"),
+ '12' : (1, "maintenance mode"),
+ '13' : (1, "firehose dump"),
+ }
-def check_blade_blades(item, _no_params, parsed):
- for key, values in parsed.iteritems():
- if item == key:
+ for line in info:
+ if line[0] == item:
# name
- yield 0, values[3]
+ yield 0, line[4]
# exist_state
- yield values[0][0], "Exists: %s" % values[0][1]
+ state, state_readable = map_exists[line[1]]
+ yield state, "Exists: %s" % state_readable
# power_state
- yield values[1][0], "Power: %s" % values[1][1]
+ state, state_readable = map_exists[line[2]]
+ yield state, "Power: %s" % state_readable
# health_state
- yield values[2][0], "Health: %s" % values[2][1]
+ state, state_readable = map_exists[line[3]]
+ yield state, "Health: %s" % state_readable
check_info["blade_blades"] = {
- 'parse_function' : parse_blade_blades,
'inventory_function' : inventory_blade_blades,
'check_function' : check_blade_blades,
'service_description' : "Blade %s",