Veritas-bu

[Veritas-bu] Script: Weekly Usage Rates

2003-07-31 18:25:17
Subject: [Veritas-bu] Script: Weekly Usage Rates
From: Mark.Donaldson AT experianems DOT com (Donaldson, Mark)
Date: Thu, 31 Jul 2003 16:25:17 -0600
A while ago, some poster wanted a way to track tape usage rates by pool.  I
though it was a useful idea for my environment so I created one.  Output
looks like this:

## Tape Usage Rates...
Pool        Demux changed    -3 in   7 days with    57.
Pool         Main changed    -1 in   7 days with    82.
Pool      Offsite changed     0 in   7 days with    24.
Pool     LongTerm changed     3 in   7 days with    24.
Pool   Oracle_DB1 changed     9 in   7 days with    45.
Pool   Oracle_DB2 changed     9 in   7 days with    43.
Pool      Scratch changed    98 in   7 days with   112.

So, over the past week, the count of tapes in the "Demux" pool dropped by
three to 57 tapes.  Scratch pool increased 98 tapes in the past week
reflecting the additional new tapes I added yesterday plus deassigned tapes
returned to the Scratch pool from other pools.

In theory, the positive & negative numbers should add to zero if the tape
count is stable.  Also, a system in "stasis" should have very little
variance in pool counts each week.  These facts are not reflected above
because I munged my output for public consumption.

This script requires an external routine (in PERL or C) to give you the
system UTC time.  Mine is called "seconds_since_epoch", replace it with
whatever you want for the same function.  This script is designed to be run
daily via cron at the same time of day.  For the first week, there's no
useful output until the history files are built.

-M

#!/bin/ksh
#Designed to be run daily at the same time of day,
#Reports on a weekly cycle of tape usage.

PATH=$PATH:/usr/openv/local:/usr/openv/netbackup/bin:/usr/openv/volmgr/bin:
PATH=$PATH/usr/openv/netbackup/bin/admincmd
export PATH

PROGNAME=`basename $0`
TMP1=/var/tmp/$PROGNAME.tmp1.$$
TMP2=/var/tmp/$PROGNAME.tmp2.$$
HIST=/usr/openv/var/$PROGNAME.hist.`date +%a`

#Create list of tapes & pools
vmquery -w -a | awk 'NR>3 && $12!="None" {print $1"\t"$12}' >$TMP2

#Call to my little C program to get UTC time
NOW=`seconds_since_epoch`

echo $NOW >$TMP1
for pool in `awk '{print $2}' $TMP2 | sort -u`
do
  count=`awk 'BEGIN {sum=0} {if ($2=="'$pool'") {sum++}} END {print sum}'
$TMP2`
  echo "${pool}:${count}" >>$TMP1
done

rm -f $TMP2

echo "## Tape Usage Rates..."
if [ ! -f $HIST ]
then
  #No history file - perhaps first run - no change rate possible
  echo "# No history file for this day - creating."
else
  #History file available
  then=`awk 'NR==1 {print $1}' $HIST`
  delta=`expr $NOW - $then`
  for pool in `awk -F: '$0~/:/ {print $1}' $HIST $TMP1 | sort -u`
  do
    #for each pool
    past=`awk -F: '$1=="'$pool'" && NR>1 {print $2}' $HIST`
    present=`awk -F: '$1=="'$pool'" && NR>1 {print $2}' $TMP1`
    [ -z "$past" ]    && past=0
    [ -z "$present" ] && present=0
    echo "$delta $past $present $pool" | \
        awk '{days=int(($1+1800)/86400)
              printf("Pool %12s changed %5d in %3d days with
%5d.\n",$4,$3-$2,days,$3)}'
  done | sort -n -k 4
fi
mv $TMP1 $HIST
exit

<Prev in Thread] Current Thread [Next in Thread>
  • [Veritas-bu] Script: Weekly Usage Rates, Donaldson, Mark <=