]> arthur.barton.de Git - nagcollect.git/blobdiff - client/lib/tests/RAID.tst
RAID.tst: use screen(1) so that promiseutil(8) has a valid tty
[nagcollect.git] / client / lib / tests / RAID.tst
index 806186ee1d8d9816ec31fb712ebef282f77abc99..859062b1280a914b7b7f3f6f3e05756b26178c07 100644 (file)
@@ -5,6 +5,7 @@ SERVICE="RAID_p"
 
 if [ `uname` = "Darwin" ]; then
        tmp=`mktemp "/tmp/$$.XXXX"`
+       tmp2=`mktemp "/tmp/$$-2.XXXX"`
        LC_ALL=C diskutil checkRAID >"$tmp" 2>/dev/null
        if [ $? -eq 0 ]; then
                # Apple Software-RAID detected
@@ -46,7 +47,34 @@ if [ `uname` = "Darwin" ]; then
                        TEXT="$TEXT  Apple HW-RAID status is unknown ($status)!?"
                fi
        fi
-       rm -f "$tmp"
+       LC_ALL=C screen -D -m sh -c "promiseutil -C array -a list -v >$tmp2"
+        grep -A8 '^LdId' "$tmp2" | 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" "$tmp2"
 elif [ `uname` = "Linux" -a -r /proc/mdstat ]; then
        status=$(cat /proc/mdstat | grep -E "(^md|^      [0-9])" \
         | while read info1; do