2 # Script to parse and rewrite the hpacucli output so we can feed it to Zabbix.
3 # sven@timegate.de - 2010-05-13
15 if [ $rawv -eq 1 ]; then
23 sudo hpacucli ctrl all show status > $clog
25 #Check if another hpacucli has been active, sleep and try again
26 if [ $(grep -c '^Another' $clog) -eq 1 ]; then
37 #Check Controller overall status
38 rawv=$(grep Controller $clog|awk '{print $3}'|grep -c OK)
42 rawv=$(grep Cache $clog|awk '{print $3}'|grep -c OK)
45 #Check for a battery and it's status if available
46 if [ $(grep -c Battery $clog) -eq 0 ]; then
49 rawv=$(grep Battery $clog|awk '{print $3}'|grep -c OK)
53 #Calculate overall status and return it
54 allstat=$(( $constat + $cachestat + $battstat ))
55 if [ $allstat -eq '0' ]; then
63 sudo hpacucli ctrl slot=0 pd all show > $clog
65 #Check if another hpacucli has been active, sleep and try again
66 if [ $(grep -c '^Another' $clog) -eq 1 ]; then
73 drivecount=$(grep -c physicaldrive $clog)
74 driveok=$(grep -c OK $clog)
76 if [ $driveok -eq $drivecount ]; then
85 while getopts ":cdh" opt; do
88 #Create a save tempfile with mktemp
89 clog=$(mktemp /var/tmp/clog.XXXXXXXXXXXX)
94 #Create a save tempfile with mktemp
95 clog=$(mktemp /var/tmp/clog.XXXXXXXXXXXX)
100 echo "HP disk and controller check version $VERSION"
102 echo "-c Outputs controler overall status as 0 or 1"
103 echo "-d Outputs disk overall status as 0 or 1"
104 echo "-h Print this help"
105 echo "Output legend: 0 equals OK, 1 indicates something went wrong"
109 echo "Unknown option: -$OPTARG"
110 echo "Try -h to get help"