Module: check_mk
Branch: master
Commit: a60379cae2184510efb934e7535c33283726f6a9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a60379cae21845…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 4 17:16:14 2014 +0100
#1653 FIX megaraid_pdisks: Resulting states are now hard coded within the check
The megaraid_pdisks check was using the state the device had during initial
inventory as expected OK state. When a device was failed during inventory,
the state never changed to CRITICAL, even if the device is failed.
This has been fixed by hard coding the resulting states now.
Online, Hotspare -> OK
Failed -> CRITICAL
---
.werks/1653 | 15 +++++++++++++++
ChangeLog | 1 +
checkman/megaraid_pdisks | 7 +------
checks/megaraid_pdisks | 26 +++++++++++++-------------
4 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/.werks/1653 b/.werks/1653
new file mode 100644
index 0000000..7e9505f
--- /dev/null
+++ b/.werks/1653
@@ -0,0 +1,15 @@
+Title: megaraid_pdisks: Resulting states are now hard coded within the check
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417709673
+Class: fix
+
+The megaraid_pdisks check was using the state the device had during initial
+inventory as expected OK state. When a device was failed during inventory,
+the state never changed to CRITICAL, even if the device is failed.
+This has been fixed by hard coding the resulting states now.
+
+Online, Hotspare -> OK
+Failed -> CRITICAL
diff --git a/ChangeLog b/ChangeLog
index 3a35158..3093406 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -105,6 +105,7 @@
* 1598 FIX: bluecat_dhcp: Check is not longer found in inventory if dhcp service is
not activated
* 1635 FIX: multipath: fix parsing output of multipath on RedHat6 with space in
alias
* 1652 FIX: kaspersky_av_quarantine: Fixed exception when a file was found in
quarantine
+ * 1653 FIX: megaraid_pdisks: Resulting states are now hard coded within the check...
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/checkman/megaraid_pdisks b/checkman/megaraid_pdisks
index 8ed296b..e348b08 100644
--- a/checkman/megaraid_pdisks
+++ b/checkman/megaraid_pdisks
@@ -19,10 +19,5 @@ item:
A combination of the enclosure and the slot number, separated by a slash, for
example {"0/4"} for enclosure {0} and slot {4}.
-parameter:
- targetstate (string): The target state of the disk as output
- by {MegaCli}.
-
inventory:
- All disks are automatically inventorized. The current state is
- taken as the target state.
+ One service is created for each found disk.
diff --git a/checks/megaraid_pdisks b/checks/megaraid_pdisks
index 9ffcd7a..61b3937 100644
--- a/checks/megaraid_pdisks
+++ b/checks/megaraid_pdisks
@@ -86,7 +86,7 @@ def megaraid_pdisks_parse(info):
elif line[0] == "Slot":
slot = int(line[-1])
elif line[0] == "Firmware" and line[1] == "state:":
- state = line[2]
+ state = line[2].rstrip(',')
elif line[0] == "Inquiry" and line[1] == "Data:":
name = " ".join(line[2:])
#Adapter, Enclosure, Encolsure Device ID, Slot, State, Name
@@ -96,31 +96,31 @@ def megaraid_pdisks_parse(info):
return return_var
-
def inventory_megaraid_pdisks(info):
-
info = megaraid_pdisks_parse(info)
inventory = []
for adapter, enclosure, enc_dev_id, slot, state, name in info:
- inventory.append(("%s%s/%s" % (adapter, enclosure, slot),
repr(state)))
+ inventory.append(("%s%s/%s" % (adapter, enclosure, slot), None))
return inventory
-def check_megaraid_pdisks(item, target_state, info):
+megaraid_pdisks_states = {
+ 'Online' : 0,
+ 'Hotspare' : 0,
+ 'Failed' : 2,
+}
+
+def check_megaraid_pdisks(item, _no_params, info):
info = megaraid_pdisks_parse(info)
for adapter, enclosure, enc_dev_id, slot, state, name in info:
if "%s%s/%s" % (adapter, enclosure, slot) == item:
- infotext = "%s (%s)" % (state, name)
- if state == target_state:
- return (0, infotext)
- else:
- return (2, infotext)
- return (3, "No disk in encl/slot %s found" % item)
-
+ print state
+ return megaraid_pdisks_states.get(state, 3), "%s (%s)" % (state,
name)
+ return 3, "No disk in encl/slot %s found" % item
check_info["megaraid_pdisks"] = {
'check_function': check_megaraid_pdisks,
'inventory_function': inventory_megaraid_pdisks,
'service_description': 'RAID PDisk Adapt/Enc/Sl %s',
- 'has_perfdata': True,
+ 'has_perfdata': False,
'group': 'raid_disk',
}