Code

Fix for regex input of '|', being output causing problems with Nagios' parsing of
[nagiosplug.git] / contrib / check_adptraid.sh
1 #! /bin/sh
2 #
3 # Modified check_sensors to check the alarm status of an Adaptec 3200S RAID
4 # controller.
5 #
6 # Scott Lambert -- lambert@lambertfam.org
7 #
8 # Tested on FreeBSD 4.7 with the adptfbsd_323.tgz package installed.  This 
9 # package installs all it's programs into /usr/dpt.
10 #
12 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
14 PROGNAME=`basename $0`
15 PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
16 REVISION=`echo '$Revision: 302 $' | sed -e 's/[^0-9.]//g'`
18 . $PROGPATH/utils.sh
20 RAIDUTIL_CMD="/usr/dpt/raidutil -A ?"
22 print_usage() {
23         echo "Usage: $PROGNAME"
24 }
26 print_help() {
27         print_revision $PROGNAME $REVISION
28         echo ""
29         print_usage
30         echo ""
31         echo "This plugin checks alarm status of Adaptec 3200S RAID controller."
32         echo ""
33         support
34         exit 0
35 }
37 case "$1" in
38         --help)
39                 print_help
40                 exit 0
41                 ;;
42         -h)
43                 print_help
44                 exit 0
45                 ;;
46         --version)
47         print_revision $PROGNAME $REVISION
48                 exit 0
49                 ;;
50         -V)
51                 print_revision $PROGNAME $REVISION
52                 exit 0
53                 ;;
54         *)
55                 raidutiloutput=`$RAIDUTIL_CMD 2>&1`
56                 status=$?
57                 if test "$1" = "-v" -o "$1" = "--verbose"; then
58                         echo ${raidutiloutput}
59                 fi
60                 if test ${status} -eq 127; then
61                         echo "RAIDUTIL UNKNOWN - command not found (did you install raidutil?)"
62                         exit -1
63                 elif test ${status} -ne 0 ; then
64                         echo "WARNING - raidutil returned state $status"
65                         exit 1
66                 fi
67                 if echo ${raidutiloutput} | egrep On > /dev/null; then
68                         echo RAID CRITICAL - RAID alarm detected!
69                         exit 2
70                 else
71                         echo raid ok
72                         exit 0
73                 fi
74                 ;;
75 esac