#!/bin/ksh # 2005-01-10 Tom Kranz (tom@siliconbunny.com) # # This script is distributed under the GNU Public License (GPL) with the # following extra conditions: # - attritbution must be maintained # - CD-ROM or similar media for commercial distribution without the prior # approval of the author # Quickie script to catch Disksuite breakage # # We store a temp file in /tmp with our errors - once the script is complete, if # that file has anything in it we know something has gone wrong - so we # email it off # Some vars PATH=/usr/sbin:/usr/opt/SUNWmd/sbin:/usr/bin # Odd path is easier than trying to work out where ODS tools have been # hidden in this OE release :-) HOSTNAME=`uname -n` # Who do we want to know about breakage? # CHANGE THIS SYSADMINS= # Setup our temp file OUTPUT=/tmp/ods_breakage.txt # We don't want any old rubbish lying around if [ -f $OUTPUT ] then rm $OUTPUT fi # Let's check to see if we actually have ODS, shall we? if [ -z "`pkginfo | grep SUNWmdg`" ] then # If we silently bail, we can just roll this out across an # estate as part of a standard toolkit # Easier to support a common toolset installed on all machines # than lots of local machine customisations exit 1 fi # Get metastat to list our mirrors MIRRORS=`metastat | grep Mirror | cut -d: -f1` # Cycle through the mirrors, looking for breakage # Feel free to add extra if loops looking for specific issues for MIRROR in $MIRRORS do if [ "`metastat $MIRROR | grep \"Needs maintenance\"`" != "" ] then echo "" >> $OUTPUT echo "WARNING:" >> $OUTPUT echo " Host $HOSTNAME reports that mirror $MIRROR needs maintenance!" >> $OUTPUT echo "" >> $OUTPUT elif [ "`metastat $MIRROR | grep \"Broken\"`" != "" ] then echo "" >> $OUTPUT echo "WARNING:" >> $OUTPUT echo " Host $HOSTNAME reports that mirror $MIRROR is *BROKEN*!" >> $OUTPUT echo "" >> $OUTPUT fi done # Now we need to check our output. If there's something there, we should email # it off to concerned parties if [ -f $OUTPUT ] then cat $OUTPUT | mailx -s "$HOSTNAME reports Disksuite anomalies!" $SYSADMINS fi # And we're done, except for the crying about dataloss, bad backups, etc. etc. exit