X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=nagcollect.git;a=blobdiff_plain;f=client%2Flib%2Ftests%2FRAID.tst;h=806186ee1d8d9816ec31fb712ebef282f77abc99;hp=d814588d4f83dd27316e8e84b84d97502850f525;hb=deca40ea27eb9990496e88db3ceec44c2cdd391b;hpb=7b25d943d4339ad8310a75806761103cb2399898 diff --git a/client/lib/tests/RAID.tst b/client/lib/tests/RAID.tst index d814588..806186e 100644 --- a/client/lib/tests/RAID.tst +++ b/client/lib/tests/RAID.tst @@ -14,10 +14,10 @@ if [ `uname` = "Darwin" ]; then statusText=`echo $statusString | sed -e 's/Status: //g' | sed -e 's/ /, /g'` if [ "$status" != "Online" ]; then STATUS=2 - TEXT="ERROR - RAID is $statusText" + TEXT="$TEXT SW-RAID is $statusText." else - STATUS=0 - TEXT="OK - RAID status is good." + [ -z "$STATUS" ] && STATUS=0 + TEXT="$TEXT SW-RAID status is good." fi fi LC_ALL=C raidutil list status 2>/dev/null | grep "RAID " >"$tmp" @@ -36,29 +36,41 @@ if [ `uname` = "Darwin" ]; then [ "$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" + [ -z "$STATUS" ] && STATUS=0 + TEXT="$TEXT Apple HW-RAID is good: $status." elif [ $bad -gt 0 ]; then STATUS=2 - TEXT="ERROR - HW-RAID status: $status" + TEXT="$TEXT Apple HW-RAID status: $status." else - STATUS=1 - TEXT="ERROR - HW-RAID status is unknown!? ($status)" + [ -z "$STATUS" -o "$STATUS" = "1" ] && STATUS=1 + TEXT="$TEXT Apple 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 + [ -z "$STATUS" ] && STATUS=0 + TEXT="$TEXT SW-RAID is good: $status." + else + STATUS=2 + TEXT="$TEXT SW-RAID status: $status." + fi fi fi + +if [ -n "$TEXT" ]; then + case "$STATUS" in + 0) TEXT="OK -${TEXT}"; ;; + 1) TEXT="WARNING -${TEXT}"; ;; + 2) TEXT="ERROR -${TEXT}"; ;; + *) TEXT="UNKNOWN -${TEXT}"; ;; + esac +fi