Module: check_mk
Branch: master
Commit: 9d219166765abb6507e982c1317eca2742e6e35a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9d219166765abb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 19 15:10:51 2010 +0200
Using the real enclosure number as check item now.
The problem with the 'enclosure device id' which was used before is
being generated somehow. So on identical hardware with identical
raid setup the 'enclosure device ids' can be different. This is a
bad behaviour when hardcoding checks for a group of hosts in check_mk.
Instead of the 'enclosure device id' the 'enclosure number' is used now.
Which is also better to identify the enclosure hardware without having
a look at the configuration.
---
ChangeLog | 2 ++
agents/check_mk_agent.linux | 5 +++++
checks/megaraid_pdisks | 29 +++++++++++++++++++++++------
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f2e9ed5..dd78e6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
1.1.9i1
+ Checks & Agents:
+ * megaraid_pdisks: Using the real enclosure number as check item now.
Multisite:
* The custom open/close states of custom links are now stored for each
user
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 40b92cc..4c8f63c 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -213,6 +213,11 @@ fi
# http://www.lsi.com/DistributionSystem/AssetDocument/support/downloads/megar…
if which MegaCli >/dev/null ; then
echo '<<<megaraid_pdisks>>>'
+ for part in $(MegaCli -EncInfo -aALL -NoLog < /dev/null | egrep 'Enclosure|Device ID'); do
+ [ $part == 'Enclosure' ] && echo -ne "\ndev2enc"
+ echo -n " ${part//:/}"
+ done
+ echo
MegaCli -PDList -aALL -NoLog < /dev/null | egrep 'Enclosure|Raw Size|Slot Number|Device Id|Firmware state|Inquiry'
echo '<<<megaraid_ldisks>>>'
MegaCli -LDInfo -Lall -aALL -NoLog < /dev/null | egrep 'Size|State|Number|Adapter|Virtual'
diff --git a/checks/megaraid_pdisks b/checks/megaraid_pdisks
index d327fca..fed9ca1 100644
--- a/checks/megaraid_pdisks
+++ b/checks/megaraid_pdisks
@@ -36,26 +36,43 @@
# Firmware state: Unconfigured(good)
# Inquiry Data: FUJITSU MBB2147RC 5204BS04P9104BSC
+# The agent provides some new information since 1.1.9.
+# The dev2enc infos are sent from the agent to have the
+# real enclosure numbers instead of the device ids which
+# seem to be generated somehow.
+#
+# dev2enc Enclosure 0 Device ID 6
+# dev2enc Enclosure 1 Device ID 252
+#
+# On new inventory runs the enclosure number is used as
+# index and item part.
+
def inventory_megaraid_pdisks(checkname, info):
inventory = []
+ dev2enc = {}
for line in info:
- if line[0] == "Enclosure":
- enclosure = int(line[-1])
+ if line[0] == "dev2enc":
+ dev2enc[line[5]] = 'e'+line[2]
+ elif line[0] == "Enclosure":
+ enclosure = dev2enc.get(line[-1], line[-1])
elif line[0] == "Slot":
slot = int(line[-1])
elif line[0] == "Firmware" and line[1] == "state:":
- inventory.append(( "%d/%d" % (enclosure, slot), "", repr(line[2]) ))
+ inventory.append(( "%s/%d" % (enclosure, slot), "", repr(line[2]) ))
return inventory
def check_megaraid_pdisks(item, target_state, info):
# item is "$ENCLOSURE/$SLOT"
# param is the target state
+ dev2enc = {}
for line in info:
- if line[0] == "Enclosure":
- enclosure = int(line[-1])
+ if line[0] == "dev2enc":
+ dev2enc[line[5]] = 'e'+line[2]
+ elif line[0] == "Enclosure":
+ enclosure = item.startswith('e') and dev2enc[line[-1]] or line[-1]
elif line[0] == "Slot":
slot = int(line[-1])
- found = "%d/%d" % (enclosure, slot) == item
+ found = "%s/%d" % (enclosure, slot) == item
elif found and line[0] == "Firmware" and line[1] == "state:":
state = line[2]
elif found and line[0] == "Inquiry" and line[1] == "Data:":