#!/bin/ksh # Medialister # 1/2002 C. Vail # # Run the available_media program from Veritas Netbackup and # do some analysis of the result. NPATH=/usr/openv/netbackup/bin/goodies # where the executable and the output go CARTLIST=$NPATH/cartlist # the output file CART=HCART # Cartridge type: either HCART or DLT TOTALSIZE="0" # these variables must be set to 0 TOTALEMPTYSIZE="0" # else bc returns an error TOTALACTIVESIZE="0" MAXSIZE="0" EMPTYSIZE=59200000 # capacity of an empty tape if test -f $NPATH/medialist then rm $NPATH/medialist fi if test -f $CARTLIST then rm $CARTLIST fi # Run the report, and extract the output file from it $NPATH/available_media >$NPATH/medialist grep $CART $NPATH/medialist|sort>$CARTLIST # Various counters AVAILABLE=`grep $CART $CARTLIST|grep AVAILABLE|wc -l|awk '{ print $1 }'` DBBACKUP=`grep $CART $CARTLIST|grep DBBACKUP|wc -l|awk '{ print $1 }'` FULL=`grep $CART $CARTLIST|grep FULL|wc -l|awk '{ print $1 }'` TOTALCARTS=`grep $CART $CARTLIST|wc -l|awk '{ print $1 }'` ACTIVE=`grep $CART $CARTLIST|grep ACTIVE|wc -l|awk '{ print $1 }'` FROZEN=`grep $CART $CARTLIST|grep FROZEN|wc -l|awk '{ print $1 }'` # Accumulate a number for SIZE in `grep $CART $CARTLIST|awk '{ print $8 }'|grep -v "-"` do TOTALSIZE=`echo "$SIZE" + "$TOTALSIZE"|bc` done # This one is a little more tricky: add up the empty space on a cartridge for ACTIVESIZE in `grep $CART $NPATH/medialist|grep ACTIVE|awk '{ print $8 }'|grep -v "-"` do THISEMPTYSIZE=`echo "$EMPTYSIZE - $ACTIVESIZE"|bc` TOTALACTIVESIZE=`echo "$THISEMPTYSIZE + $TOTALACTIVESIZE" | bc` done # More math TOTALEMPTY=`echo "$TOTALACTIVESIZE + ($AVAILABLE * $EMPTYSIZE)"|bc` MAXSIZE=`echo "$TOTALCARTS*$EMPTYSIZE"|bc` SIZEPCT=`echo "scale=3;100*($TOTALSIZE/$MAXSIZE)"|bc` # Tack the summary onto the output file echo "Total Carts Available: $AVAILABLE\tBytes: $TOTALEMPTY">>$CARTLIST echo "Total Carts Frozen: $FROZEN">>$CARTLIST echo "Total Carts in DBbackup: $DBBACKUP">>$CARTLIST echo "Total Carts Active: $ACTIVE">>$CARTLIST echo "Total Carts Full: $FULL">>$CARTLIST echo "Total Carts: $TOTALCARTS\tBytes: $MAXSIZE">>$CARTLIST echo "Total Bytes: $TOTALSIZE\t$SIZEPCT%">>$CARTLIST # mail the results if test -f medialister.maillist then for DEST in `cat medialister.maillist` do cat $NPATH/cartlist|mailx -s "Tape Media List" $DEST done f