#! /bin/sh # # Usage: ./check_metastat # # Description: # # # Output: # # # Notes: # # # Examples: # # # Paths to commands used in this script. These # may have to be modified to match your system setup. result="" PATH="" ECHO="/usr/bin/echo" GREP="/usr/bin/grep" DF="/usr/bin/df" DIFF="/usr/bin/diff" TAIL="/usr/bin/tail" CAT="/usr/bin/cat" RM="/usr/bin/rm" WC="/usr/bin/wc" METASTAT="/usr/opt/SUNWmd/sbin/metastat" PROGNAME=`/usr/bin/basename $0` PROGPATH=`echo $0 | /usr/bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` REVISION=`echo '$Revision: 0.1 $' | /usr/bin/sed -e 's/[^0-9.]//g'` . $PROGPATH/utils.sh print_usage() { echo "Usage: $PROGNAME -F logfile -O oldlog -q query" echo "Usage: $PROGNAME --help" echo "Usage: $PROGNAME --version" } print_help() { print_revision $PROGNAME $REVISION echo "" print_usage echo "" echo "Check Metastat output for disk that need maintenance" echo "" support } # Make sure the correct number of command line # arguments have been supplied #if [ $# -lt 1 ]; then #print_usage #exit $STATE_UNKNOWN #fi # Grab the command line arguments exitstatus=$STATE_WARNING #default while test -n "$1"; do case "$1" in --help) print_help exit $STATE_OK ;; -h) print_help exit $STATE_OK ;; --version) print_revision $PROGNAME $VERSION exit $STATE_OK ;; -V) print_revision $PROGNAME $VERSION exit $STATE_OK ;; -x) exitstatus=$2 shift ;; --exitstatus) exitstatus=$2 shift ;; *) echo "Unknown argument: $1" print_usage exit $STATE_UNKNOWN ;; esac shift done # check to make sure metadevices are used BLAH=`$DF |$GREP /dev/md` DFOUT=$? if [ ! $DFOUT -eq 0 ]; then $ECHO "No metadevices on this system!\n" exit $STATE_UNKNOWN fi if [ ! -x $METASTAT ]; then $ECHO "Metastat not found.\n" exit $STATE_UNKNOWN fi LINES=`$METASTAT | $GREP 'State:' | $GREP -v 'Okay' | $WC -l` if [ $LINES -eq 0 ]; then $ECHO "OK - All metadevices are stable : " a=`/usr/opt/SUNWmd/sbin/metastat|/usr/bin/grep c0|/usr/bin/awk '{print $1 " " $4 " " $5 " " $6 ":"}'` result="$a" echo $result exit $STATE_OK else $ECHO "ERROR - Metadevices need Maintainence : " a=`/usr/opt/SUNWmd/sbin/metastat|/usr/bin/grep c0|/usr/bin/awk '{print $1 " " $4 " " $5 " " $6 ":"}'` result="$a" echo $result exit $STATE_CRITICAL fi exit $exitstatus