#/bin/sh!
# --------------------------------------
# Stefano Vicenzoni   28-01-2008
#
#  in Nagios directory define checkcommands line:
#
#	define command{
#		command_name    Check_array_ccis
#		command_line    $USER1$/Check_array_ccis $HOSTADDRESS$ $ARG1$
#		}
#  
#  and in service
#
#	define service{
#		use                     generic
#		host_name               hostname
#		service_description     yourdescription
#		check_command           Check_array_ccis!X
#		}
#                                        where X = number of logical array (0 or 1 or 2..)
#
#   Tested with Smart Array 6i 5i on Windows server with service snmp active for your community. 
#
HOST=$1
OK=$2
WARN=$3
CRIT=$4
RETVAL=0
#
# modify next line  with your community !!
#
UNIT=`/usr/bin/snmpwalk -v 1 -c COMMUNITYNAME -On $1 1.3.6.1.4.1.232.3.2.3.1.1.4.0.$2 | tail -1 | awk '{print \$4}'`
#
RETVAL=$?
#
if [ $UNIT = 2 ]; then
             echo "Array status OK"
             RETVAL=0    
    else 
             echo "Array errors!! Check Status code: $UNIT"
             RETVAL=2     
fi
exit $RETVAL