]> arthur.barton.de Git - nagcollect.git/blob - client/lib/tests/RAID.tst
Don't include Mac OS X resource forks in tar archives
[nagcollect.git] / client / lib / tests / RAID.tst
1 # NagCollect -- Nagios Data Collector for Passive Checks
2 # Copyright (c)2009 Alexander Barton, alex@barton.de
3
4 SERVICE="RAID_p"
5
6 if [ `uname` = "Darwin" ]; then
7         tmp=`mktemp "/tmp/$$.XXXX"`
8         LC_ALL=C diskutil checkRAID >"$tmp"
9         if [ $? -eq 0 ]; then
10                 # Apple Software-RAID detected
11                 statusText=`grep "^Status:" "$tmp"`
12                 status=`echo $statusText | cut -d' ' -f2-`
13                 if [ "$status" != "Online" ]; then
14                         STATUS=2
15                         TEXT="ERROR - RAID is $status"
16                 else
17                         STATUS=0
18                         TEXT="OK - RAID status is good."
19                 fi
20         fi
21         rm -f "$tmp"
22 elif [ `uname` = "Linux" ]; then
23         status=$(cat /proc/mdstat | grep -E "(^md|^      [0-9])" | while read info1; do
24                 read info2
25                 dev=`echo $info1 | cut -d' ' -f1`
26                 stat=`echo $info2 | cut -d'[' -f 3 | cut -d']' -f1`
27                 echo -n " $dev:$stat"
28         done)
29         if [ "`echo $status | tr -d 'md0123456789: U'`" = "" ]; then
30                 STATUS=0
31                 TEXT="OK - RAID is good: $status"
32         else
33                 STATUS=2
34                 TEXT="ERROR - RAID status: $status"
35         fi
36 fi