#!/bin/ksh # #ident "@(#)mediatorcheck.ksh 1.0 10/01/18 SMI" # Copyright (c) 2010 by Sun Microsystems, Inc. # # Entry in root crontab might be: # 00 04 * * * /mediatorcheck.ksh >/dev/null 2>&1 # # Choose syslog, mail or both REPORT="syslog mail" # default is root, or enter mail address list MAILTO=${*:-"root"} # LOGGER="/bin/logger -p cron.alert -t MEDIATOR-status " SVMLOG=/tmp/mediatorcheck-log MDBIN=/usr/sbin METASET=${MDBIN}/metaset MEDSTAT=${MDBIN}/medstat AWK=/usr/bin/awk MAILX=/usr/bin/mailx RM=/usr/bin/rm EGREPV="/usr/bin/egrep -v" HOSTNAME=`/usr/bin/hostname` date=`${/usr/bin/date} '+%T %B %e %Y'` report () { for i in $REPORT ; do case $i in "syslog") $LOGGER $@ ;; "mail") print $@ >> ${SVMLOG}.$$ ;; *) print $@ ;; esac done } mailing () { for i in $REPORT ; do if [ $i = "mail" ]; then ${MAILX} -s "${HOSTNAME} MEDIATOR problems ${date}" ${MAILTO} < ${SVMLOG}.$$ ${RM} -f ${SVMLOG}.$$ fi done } for diskset in `${METASET} 2>/dev/null | egrep -e "Set name" | sed s/"Multi-owner "// | awk '{print $4}' | sed s/,.*//` do if [ $diskset ] ; then metaparam="-s "$diskset fi # Check the medstat state, if the state is not Ok then something is wrong mdtrouble=`${MEDSTAT} $metaparam | \ ${AWK} '{ if ( $2 != "Ok" ) print $0 }' | ${EGREPV} Mediator` if [ "${mdtrouble}" ]; then report " Mediator are not Ok" report " See ${MEDSTAT} ${metaparam} " fi done # # If Mail logging, and errors occurred, then mail the report mailing #