1 # NagCollect -- Nagios Data Collector for Passive Checks
2 # Copyright (c)2009-2011 Alexander Barton, alex@barton.de
6 if [ `uname` = "Darwin" ]; then
7 tmp=`mktemp "/tmp/$$.XXXX"`
8 LC_ALL=C diskutil checkRAID >"$tmp"
10 # Apple Software-RAID detected
11 statusString1=`grep "^Status:" "$tmp" | uniq`
12 status=`echo $statusString1 | sed -e 's/Status: //g'`
13 statusString=`grep "^Status:" "$tmp"`
14 statusText=`echo $statusString | sed -e 's/Status: //g' | sed -e 's/ /, /g'`
15 if [ "$status" != "Online" ]; then
17 TEXT="ERROR - RAID is $statusText"
20 TEXT="OK - RAID status is good."
23 LC_ALL=C raidutil list status | grep "RAID " >"$tmp"
25 # Apple Hardware-RAID detected
30 v=`echo "$x" | cut -d' ' -f1`
31 s=`echo "$x" | cut -b67- | sed -e 's/://g'`
32 s2=`echo "$x" | cut -b78-`
34 && status="$status, $v:$s" \
36 [ "$s2" = "Good" ] && good=$good+1 || bad=bad+1
38 if [ $bad -eq 0 -a $good -ge 1 ]; then
40 TEXT="OK - HW-RAID is good: $status"
41 elif [ $bad -gt 0 ]; then
43 TEXT="ERROR - HW-RAID status: $status"
46 TEXT="ERROR - HW-RAID status is unknown!? ($status)"
50 elif [ `uname` = "Linux" -a -r /proc/mdstat ]; then
51 status=$(cat /proc/mdstat | grep -E "(^md|^ [0-9])" | while read info1; do
53 dev=`echo $info1 | cut -d' ' -f1`
54 stat=`echo $info2 | cut -d'[' -f 3 | cut -d']' -f1`
57 if [ "`echo $status | tr -d 'md0123456789: U'`" = "" ]; then
59 TEXT="OK - RAID is good: $status"
62 TEXT="ERROR - RAID status: $status"