RAID.tst: Add support for Promise Hardware-RAID
authorAlexander Barton <alex@barton.de>
Fri, 10 Aug 2012 10:16:25 +0000 (12:16 +0200)
committerAlexander Barton <alex@barton.de>
Fri, 10 Aug 2012 10:16:25 +0000 (12:16 +0200)
client/lib/tests/RAID.tst

index 806186e..51c785c 100644 (file)
@@ -46,6 +46,33 @@ if [ `uname` = "Darwin" ]; then
                        TEXT="$TEXT  Apple HW-RAID status is unknown ($status)!?"
                fi
        fi
+       LC_ALL=C promiseutil -C array -a list -v 2>/dev/null </dev/tty \
+         | grep -A8 '^LdId' | grep '^[0-9]' >"$tmp"
+       if [ $? -eq 0 ]; then
+               # Promise Hardware-RAID detected
+               declare -i good=0
+               declare -i bad=0
+               status=""
+               while read x; do
+                       v=`echo "$x" | awk "{ print \\$2 }"`
+                       z=`echo "$x" | awk "{ print \\$3 }"`
+                       s=`echo "$x" | awk "{ print \\$4 }"`
+                       [ -n "$status" ] \
+                               && status="$status, $v($z):$s" \
+                               || status="$v($z):$s"
+                       [ "$s" = "OK" ] && good=$good+1 || bad=bad+1
+               done <"$tmp"
+               if [ $bad -eq 0 -a $good -ge 1 ]; then
+                       [ -z "$STATUS" ] && STATUS=0
+                       TEXT="$TEXT Promise HW-RAID is good: $status."
+               elif [ $bad -gt 0 ]; then
+                       STATUS=2
+                       TEXT="$TEXT Promise HW-RAID status: $status."
+               else
+                       [ -z "$STATUS" -o "$STATUS" = "1" ] && STATUS=1
+                       TEXT="$TEXT  Promise HW-RAID status is unknown ($status)!?"
+               fi
+       fi
        rm -f "$tmp"
 elif [ `uname` = "Linux" -a -r /proc/mdstat ]; then
        status=$(cat /proc/mdstat | grep -E "(^md|^      [0-9])" \