#!/bin/ksh PATH=$PATH:/usr/openv/volmgr/bin PROGNAME=`basename $0` ## ## Email Address for report ## ADDR="YOU @ YOURDOMAIN.COM" DDIR=/var/tmp DBASE=${PROGNAME}_datafile DFILE=$DDIR/$DBASE.`date +%m_%d_%Y` OUTF=$DDIR/$PROGNAME.out # #Limiter to counting range of drive indexes (indicies?) MIN=0 MAX=99 if [ ! -f $DFILE -o -n "$1" ] then # New data collection file. Process previous datafile first if [ -n "$1" ] then lastfile=$1 else lastfile=`ls -tr $DDIR/$DBASE* 2>/dev/null | tail -1` fi if [ -n "$lastfile" ] then [ -f $OUTF ] && rm $OUTF exec >$OUTF 2>&1 #Header awk 'BEGIN{HR=-1;MN=0;printf(" ")} {if ($2==0) {if ($1!=HR) {HR=$1 if (HR<10) {printf("0%1d",HR)} else {printf("%2d",HR)} } else {printf("-")} }} END {printf("\n")}' $lastfile #Create Graph for drive in `awk '{print $2}' $lastfile| sort -nu` do awk 'BEGIN {HR=0;printf("%2s |",'$drive')} {if ($2=='$drive') {if ($1!=HR) {HR=$1;printf("|%s",$3)} else {printf("%s",$3)}}} END {printf("|\n")}' $lastfile done #Availability Calcs GDA=`awk 'BEGIN {sample=0;up=0} { sample++ ; if ($3=="-") {up++}} END {printf ("%3.1f",up/sample*100)}' $lastfile` echo "\n## Drive Availability: ${GDA}%" for drive in `awk '{print $2}' $lastfile| sort -nu` do awk 'BEGIN {sample=0;up=0} {if ($2=='$drive') { sample++ ; if ($3=="-") {up++}}} END {printf("Drive %2s = %3d%%\t",'$drive',(up/sample)*100) if(('$drive'%4)==3) {printf("\n")}}' $lastfile done echo "\n## Report Done" mailx -s "NB Rpt: Drive Graph: `basename $lastfile|cut -f2 -d.` - hcart2" $ADDR <$OUTF if [ -z "$1" ] then #keep history of input & output files [ -f $OUTF.2 ] && mv $OUTF.2 $OUTF.3 [ -f $OUTF.1 ] && mv $OUTF.1 $OUTF.2 mv $OUTF $OUTF.1 compress $lastfile [ -f $lastfile.2.Z ] && mv $lastfile.2.Z $lastfile.3.Z [ -f $lastfile.1.Z ] && mv $lastfile.1.Z $lastfile.2.Z mv $lastfile.Z $lastfile.1.Z fi fi fi #add to current datafile if [ -z "$1" ] then HR=`date +%H` ## ## Note "hcart" below. Change if needed to your tape type ## Note: MAX & MIN are variables set above to limit the view ## vmoprcmd -d ds | awk '$2~/hcart/ && \ $1~/^[0-9]/ && \ $1<='$MAX' && $1>='$MIN' {if ($3~/DOWN/) {print '$HR',$1,"D"} else { if ($3~/PEND/) {print '$HR',$1,"P"} else { if ($3~/AVR/) {print '$HR',$1,"A"} else { if ($4=="-") {print '$HR',$1,"-"} else { print '$HR',$1,"#"}}}}}' >>$DFILE fi exit