Module: check_mk
Branch: master
Commit: 95bcdfd7ee7870da04ee07f6d68a9a92dfe1f63e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=95bcdfd7ee7870…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Nov 7 15:51:15 2016 +0100
storcli_pdisks, storcli_vdrive: Use params instead of hardcoded state interpretation
---
checks/storcli_pdisks | 34 ++++++++++++++++++----------------
checks/storcli_vdrives | 39 +++++++++++++++++++--------------------
2 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/checks/storcli_pdisks b/checks/storcli_pdisks
index d89253f..cce58f6 100644
--- a/checks/storcli_pdisks
+++ b/checks/storcli_pdisks
@@ -24,6 +24,15 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+factory_settings["storcli_pdisks_default_levels"] = {
+ "Dedicated Hot Spare" : 0,
+ "Global Hot Spare" : 0,
+ "Unconfigured Good" : 0,
+ "Unconfigured Bad" : 1,
+ "Online" : 0,
+ "Offline" : 2,
+}
+
def parse_storcli_pdisks(info):
@@ -56,32 +65,25 @@ def parse_storcli_pdisks(info):
def inventory_storcli_pdisks(parsed):
for item in parsed:
- yield (item, None)
+ yield (item, {})
-def check_storcli_pdisks(item, _no_params, parsed):
+def check_storcli_pdisks(item, params, parsed):
infotext = "Size: %f %s" % parsed[item]["size"]
diskstate = parsed[item]["state"]
- state_severities = {
- "Dedicated Hot Spare" : 0,
- "Global Hot Spare" : 0,
- "Unconfigured Good" : 0,
- "Unconfigured Bad" : 1,
- "Online" : 0,
- "Offline" : 2,
- }
-
infotext += ", Disk State: %s" % diskstate
- status = state_severities.get(diskstate, 3)
+
+ status = params.get(diskstate, 3)
return status, infotext
check_info["storcli_pdisks"] = {
- "parse_function" : parse_storcli_pdisks,
- "inventory_function" : inventory_storcli_pdisks,
- "check_function" : check_storcli_pdisks,
- "service_description" : "RAID PDisk EID:Slot-Device %s"
+ "default_levels_variable" : "storcli_pdisks_default_levels",
+ "parse_function" : parse_storcli_pdisks,
+ "inventory_function" : inventory_storcli_pdisks,
+ "check_function" : check_storcli_pdisks,
+ "service_description" : "RAID PDisk EID:Slot-Device %s"
}
diff --git a/checks/storcli_vdrives b/checks/storcli_vdrives
index f4c8094..223e9d8 100644
--- a/checks/storcli_vdrives
+++ b/checks/storcli_vdrives
@@ -24,10 +24,18 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+factory_settings["storcli_vdrives_default_levels"] = {
+ "Optimal" : 0,
+ "Partially Degraded" : 1,
+ "Degraded" : 2,
+ "Offline" : 1,
+ "Recovery" : 1,
+}
+
def parse_storcli_vdrives(info):
- raid_statedict = {
+ raid_statenames = {
"Optl" : "Optimal",
"Pdgd" : "Partially Degraded",
"dgrd" : "Degraded",
@@ -45,7 +53,7 @@ def parse_storcli_vdrives(info):
item, raid_type, rawstate, access, consistent = line[:5]
parsed[item] = {
"raid_type" : raid_type,
- "state" : raid_statedict.get(rawstate, rawstate),
+ "state" : raid_statenames.get(rawstate, rawstate),
"access" : access,
"consistent" : consistent,
}
@@ -57,10 +65,10 @@ def parse_storcli_vdrives(info):
def inventory_storcli_vdrives(parsed):
for item in parsed:
- yield (item, None)
+ yield (item, {})
-def check_storcli_vdrives(item, _no_params, parsed):
+def check_storcli_vdrives(item, params, parsed):
yield 0, "Raid type is " + parsed[item]["raid_type"]
yield 0, "Access: " + parsed[item]["access"]
@@ -72,24 +80,15 @@ def check_storcli_vdrives(item, _no_params, parsed):
device_state = parsed[item]["state"]
infotext = "State is %s" % device_state
- if device_state == "Optimal":
- status = 0
- elif device_state == "Partially Degraded":
- status = 1
- elif device_state == "Degraded":
- status = 2
- elif device_state == "Offline":
- status = 1
- elif device_state == "Recovery":
- status = 1
- else:
- status = 3
+
+ status = params.get(device_state, 3)
yield status, infotext
check_info["storcli_vdrives"] = {
- "parse_function" : parse_storcli_vdrives,
- "inventory_function" : inventory_storcli_vdrives,
- "check_function" : check_storcli_vdrives,
- "service_description" : "RAID Virtual Drive %s"
+ "default_levels_variable" : "storcli_vdrives_default_levels",
+ "parse_function" : parse_storcli_vdrives,
+ "inventory_function" : inventory_storcli_vdrives,
+ "check_function" : check_storcli_vdrives,
+ "service_description" : "RAID Virtual Drive %s"
}