]> arthur.barton.de Git - nagcollect.git/blobdiff - client/lib/tests/RAID.tst
RAID.tst (Linux): don't report empty status when no RAID exists
[nagcollect.git] / client / lib / tests / RAID.tst
index 074113d65c648164268c1f200687a88ac5b3054e..048d45bef91cd1179ae029bf51220a16e89e0279 100644 (file)
@@ -5,7 +5,7 @@ SERVICE="RAID_p"
 
 if [ `uname` = "Darwin" ]; then
        tmp=`mktemp "/tmp/$$.XXXX"`
-       LC_ALL=C diskutil checkRAID >"$tmp"
+       LC_ALL=C diskutil checkRAID >"$tmp" 2>/dev/null
        if [ $? -eq 0 ]; then
                # Apple Software-RAID detected
                statusString1=`grep "^Status:" "$tmp" | uniq`
@@ -20,7 +20,7 @@ if [ `uname` = "Darwin" ]; then
                        TEXT="OK - RAID status is good."
                fi
        fi
-       LC_ALL=C raidutil list status | grep "RAID " >"$tmp"
+       LC_ALL=C raidutil list status 2>/dev/null | grep "RAID " >"$tmp"
        if [ $? -eq 0 ]; then
                # Apple Hardware-RAID detected
                declare -i good=0
@@ -48,17 +48,20 @@ if [ `uname` = "Darwin" ]; then
        fi
        rm -f "$tmp"
 elif [ `uname` = "Linux" -a -r /proc/mdstat ]; then
-       status=$(cat /proc/mdstat | grep -E "(^md|^      [0-9])" | while read info1; do
+       status=$(cat /proc/mdstat | grep -E "(^md|^      [0-9])" \
+        | while read info1; do
                read info2
                dev=`echo $info1 | cut -d' ' -f1`
                stat=`echo $info2 | cut -d'[' -f 3 | cut -d']' -f1`
                echo -n " $dev:$stat"
        done)
-       if [ "`echo $status | tr -d 'md0123456789: U'`" = "" ]; then
-               STATUS=0
-               TEXT="OK - RAID is good: $status"
-       else
-               STATUS=2
-               TEXT="ERROR - RAID status: $status"
+       if [ -n "$status" ]; then
+               if [ "`echo $status | tr -d 'md0123456789: U'`" = "" ]; then
+                       STATUS=0
+                       TEXT="OK - RAID is good: $status"
+               else
+                       STATUS=2
+                       TEXT="ERROR - RAID status: $status"
+               fi
        fi
 fi