X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=client%2Flib%2Ftests%2FRAID.tst;h=048d45bef91cd1179ae029bf51220a16e89e0279;hb=b29552015c28f4742f715989ee498876ce621992;hp=8b537e5660249a645d09489b3caada91332f3fb3;hpb=40f58119d52082bc216795d142823bd63d5deffb;p=nagcollect.git diff --git a/client/lib/tests/RAID.tst b/client/lib/tests/RAID.tst index 8b537e5..048d45b 100644 --- a/client/lib/tests/RAID.tst +++ b/client/lib/tests/RAID.tst @@ -1,17 +1,17 @@ # NagCollect -- Nagios Data Collector for Passive Checks -# Copyright (c)2009-2010 Alexander Barton, alex@barton.de +# Copyright (c)2009-2011 Alexander Barton, alex@barton.de 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` status=`echo $statusString1 | sed -e 's/Status: //g'` statusString=`grep "^Status:" "$tmp"` - statusText=`echo $statusStringAll | sed -e 's/Status: //g' | sed -e 's/ /, /g'` + statusText=`echo $statusString | sed -e 's/Status: //g' | sed -e 's/ /, /g'` if [ "$status" != "Online" ]; then STATUS=2 TEXT="ERROR - RAID is $statusText" @@ -20,19 +20,48 @@ if [ `uname` = "Darwin" ]; then TEXT="OK - RAID status is good." fi fi + LC_ALL=C raidutil list status 2>/dev/null | grep "RAID " >"$tmp" + if [ $? -eq 0 ]; then + # Apple Hardware-RAID detected + declare -i good=0 + declare -i bad=0 + status="" + while read x; do + v=`echo "$x" | cut -d' ' -f1` + s=`echo "$x" | cut -b67- | sed -e 's/://g'` + s2=`echo "$x" | cut -b78-` + [ -n "$status" ] \ + && status="$status, $v:$s" \ + || status="$v:$s" + [ "$s2" = "Good" ] && good=$good+1 || bad=bad+1 + done <"$tmp" + if [ $bad -eq 0 -a $good -ge 1 ]; then + STATUS=0 + TEXT="OK - HW-RAID is good: $status" + elif [ $bad -gt 0 ]; then + STATUS=2 + TEXT="ERROR - HW-RAID status: $status" + else + STATUS=1 + TEXT="ERROR - 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])" | 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