#!/bin/bash # Adaptec AAC-RAID plugin for Nagios # Written by M.Koettenstorfer (mko@lihas.de) # Last Modified: 06-11-2008 # set -x # # Description: # # This plugin will check the status of a local # Adaptec AAC-RAID. It will provide how errors happen # # where arcconf lives RUNARCONF="/usr/StorMan/arcconf" ARCONFLISTSTATE="$RUNARCONF GETLOGS 1 DEVICE tabular" # Nagios return codes STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 STATE_DEPENDENT=4 if [ ! -x "$RUNARCONF" ] then echo "UNKNOWN: $ARCONFLISTSTATE not found or is not executable by the nagios user" exitstatus=$STATE_UNKNOWN exit $exitstatus fi PROGNAME=`basename $0` print_usage() { echo "Usage: $PROGNAME SOME OPTIONS>" echo "" echo "Notes:" echo "-w: WARNING level for errors" echo "-c: CRITICAL level for errors" echo "" } print_help() { print_usage echo "" echo "This plugin will check the howmany errors happend on Raid Controller." echo "" exit 0 } check_error_count() { if [ "$allerrors" -ge "$critlevel" ] then MESSAGE="RAID CRITICAL, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors" exitstatus=$STATE_CRITICAL elif [ "$allerrors" -ge "$critlevel" ] then MESSAGE="RAID WARNING, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors" exitstatus=$STATE_WARNING else MESSAGE="RAID OK, $numParityErrors numParityErrors, $hwErrors hwErrors, $mediumErrors mediumErrors" exitstatus=$STATE_OK fi } if [ $# -lt 4 ]; then print_usage exit $STATE_UNKNOWN fi exitstatus=$STATE_UNKNOWN #default while test -n "$1"; do case "$1" in --help) print_help exit $STATE_OK ;; -h) print_help exit $STATE_OK ;; -w) warnlevel=$2 shift ;; -c) critlevel=$2 shift ;; esac shift done # Check arguments for validity if [ $warnlevel -lt $critlevel ] # Do the warn/crit values make sense? then echo "CRITICAL value of $warnlevel less than WARNING level of $critlevel" print_usage exitstatus=$STATE_UNKNOWN exit $exitstatus elif [ -n $library ] then TMP=`mktemp -t numerrors.XXXXXX` # Create a tmpfile to store the full test result HTMP=`mktemp -t hwerrors.XXXXXX` # Create a tmpfile to store the full test result MTMP=`mktemp -t mediumerrors.XXXXXX` # Create a tmpfile to store the full test result $ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep numParityErrors| awk '{print $3}' > $TMP $ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep hwErrors | awk '{print $3}' > $HTMP $ARCONFLISTSTATE | grep Err | grep -v smart | grep -v drive | grep mediumErrors | awk '{print $3}' > $MTMP numParityErrors=`a=$(cat $TMP) ; echo $a | tr ' ' '+'| bc` hwErrors=`a=$(cat $HTMP) ; echo $a | tr ' ' '+'| bc` mediumErrors=`a=$(cat $MTMP) ; echo $a | tr ' ' '+'| bc` allerrors=`echo "$numParityErrors + $hwErrors + $mediumErrors" | bc` check_error_count rm -rf $TMP rm -rf $HTMP rm -rf $MTMP fi echo $MESSAGE exit $exitstatus