Veritas-bu

[Veritas-bu] Graphing Drive Usage

2004-05-18 18:34:53
Subject: [Veritas-bu] Graphing Drive Usage
From: Mark.Donaldson AT cexp DOT com (Mark.Donaldson AT cexp DOT com)
Date: Tue, 18 May 2004 16:34:53 -0600
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C43D27.FB3E672A
Content-Type: text/plain;
        charset="iso-8859-1"

This is kind of fun.  I've snipped the output at 13:00 hours just to keep
the wrapped-line problem from making this look bad.  It's created by little
script I whumped together over the past couple days.  Run it in cron.  I use
four samples an hour to create this (at 01,16,31,46 * * * *).  The report is
generated at midnight & mailed.  Drives down the left column, hour marks
across the top.

It's not complete accurate.  If a tape is mounted & dismounted between
sample periods, it's missed.  If a tape is mounted at a sample time but
dismounted moments later, then it counts for the whole sample period.  Call
it sampling error and don't worry about it too much.  Fine-point accuracy is
beyond the scope of this tool.

More frequent sampling is possible, if you want to handle slightly elevated
load (vmoprcmd -d ds) and wider output graph.  Less frequent is possible,
too, but anything under two samples per hour is going to mess up the header
across the top of the graph and increases the sampling error.

I'd love to make something that sweeps hyper-accurate info from the jobs DB
but that's too much detail work for now.

Anyway, if you want to play with this, the script is below.

-M

  00---01---02---03---04---05---06---07---08---09---10---11---12---13
 0 |-##-|-###|####|####|#---|----|----|----|----|----|----|----|----|
 1 |-###|###-|--#-|-###|#---|----|----|----|----|----|----|----|-#--|
 2 |----|----|--#-|-##-|----|----|----|----|----|----|----|----|----|
 3 |----|---#|####|####|####|####|----|----|----|----|--#-|----|----|
 4 |####|####|####|####|####|##--|----|----|-###|----|----|---#|#-#-|
 5 |-###|####|####|####|#---|----|----|----|----|----|---#|#---|----|
 6 |----|----|----|---#|###-|----|----|----|----|----|-#--|----|#-#-|
 7 |-###|####|####|#--#|#---|-#--|----|----|-#--|----|---#|----|----|
 8 |----|----|----|----|-#--|----|----|----|----|----|--##|----|-#--|
 9 |----|----|----|----|-#--|----|----|----|----|--#-|----|----|----|
10 |-#--|----|----|-#--|----|----|----|----|----|----|-#--|----|----|
11 |-##-|----|----|-#--|-#--|----|----|----|-###|----|----|----|----|
12 |----|-#--|----|----|----|-###|####|####|####|####|###-|----|----|
13 |----|----|----|-#--|-###|#---|----|----|--#-|----|----|----|----|
14 |----|----|----|----|----|----|----|----|----|----|--#-|----|----|
15 |----|-#--|-#--|-#--|-#--|-#--|----|----|----|----|----|----|----|
16 |####|####|####|####|####|####|####|####|####|####|####|####|####|
17 |-###|####|####|####|#---|----|----|----|----|----|----|----|----|
18 |----|----|----|-#--|----|--##|####|####|####|####|##--|----|----|
19 |----|----|----|-#--|----|----|----|----|-#--|----|----|----|----|

## Drive Availability
Drive  0 =  78% Drive  1 =  81% Drive  2 =  95% Drive  3 =  70% 
Drive  4 =  56% Drive  5 =  72% Drive  6 =  89% Drive  7 =  73% 
Drive  8 =  93% Drive  9 =  96% Drive 10 =  95% Drive 11 =  89% 
Drive 12 =  63% Drive 13 =  86% Drive 14 =  98% Drive 15 =  90% 
Drive 16 =   0% Drive 17 =  75% Drive 18 =  67% Drive 19 =  96% 


------_=_NextPart_000_01C43D27.FB3E672A
Content-Type: application/octet-stream;
        name="drive_graph.ksh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="drive_graph.ksh"

#!/bin/ksh=0A=
=0A=
PATH=3D$PATH:/usr/openv/volmgr/bin=0A=
PROGNAME=3D`basename $0`=0A=
=0A=
ADDR=3D"you AT yourdomain DOT com"=0A=
=0A=
DDIR=3D/var/tmp=0A=
DBASE=3D${PROGNAME}_datafile=0A=
DFILE=3D$DDIR/$DBASE.`date +%m_%d_%Y`=0A=
OUTF=3D$DDIR/$PROGNAME.out=0A=
=0A=
if [ ! -f $DFILE -o -n "$1" ]=0A=
then=0A=
  # New data collection file. Process previous datafile first=0A=
  if [ -n "$1" ]=0A=
  then=0A=
    #This piece is so you can run this script on demand with a =
specified=0A=
    # file as the input datafile on the command line=0A=
    lastfile=3D$1=0A=
  else=0A=
    lastfile=3D`ls -tr $DDIR/$DBASE* 2>/dev/null | tail -1`=0A=
  fi=0A=
  if [ -n "$lastfile" ]=0A=
  then=0A=
    [ -f $OUTF ] && rm $OUTF=0A=
    exec >$OUTF 2>&1=0A=
    #Header=0A=
    awk 'BEGIN{HR=3D-1;MN=3D0;printf("  ")} {if ($2=3D=3D0) {if =
($1!=3DHR) {HR=3D$1=0A=
                                         if (HR<10) {printf("0%1d",HR)} =
else {printf("%2d",HR)}=0A=
                                        } else {printf("-")} =0A=
                           }} END {printf("\n")}' $lastfile =0A=
 =0A=
    #Create Graph=0A=
    for drive in `awk '{print $2}' $lastfile| sort -nu`=0A=
    do=0A=
      awk 'BEGIN {HR=3D0;printf("%2s |",'$drive')} =0A=
           {if ($2=3D=3D'$drive') {if ($1!=3DHR) =
{HR=3D$1;printf("|%s",$3)} else {printf("%s",$3)}}}=0A=
           END {printf("|\n")}' $lastfile =0A=
    done =0A=
=0A=
    echo "\n## Drive Availability" =0A=
    #Availability Calcs=0A=
    for drive in `awk '{print $2}' $lastfile| sort -nu`=0A=
    do=0A=
      awk 'BEGIN {sample=3D0;up=3D0}=0A=
           {if ($2=3D=3D'$drive') { sample++ ; if ($3=3D=3D"-") =
{up++}}}=0A=
           END {printf("Drive %2s =3D =
%3d%%\t",'$drive',(up/sample)*100)=0A=
                if(('$drive'%4)=3D=3D3) {printf("\n")}}' $lastfile =0A=
    done  =0A=
    =0A=
    echo "\n## Report Done" =0A=
    mailx -s "Drive Graph: `basename $lastfile|cut -f2 -d.`" $ADDR =
<$OUTF=0A=
=0A=
    if [ -z "$1" ]=0A=
    then=0A=
      #keep history of input & output files=0A=
      [ -f $OUTF.2 ] && mv $OUTF.2 $OUTF.3=0A=
      [ -f $OUTF.1 ] && mv $OUTF.1 $OUTF.2=0A=
      mv $OUTF  $OUTF.1=0A=
      compress $lastfile=0A=
      [ -f $lastfile.2.Z ] && mv $lastfile.2.Z $lastfile.3.Z=0A=
      [ -f $lastfile.1.Z ] && mv $lastfile.1.Z $lastfile.2.Z=0A=
      mv $lastfile.Z   $lastfile.1.Z=0A=
    fi=0A=
  fi=0A=
fi=0A=
#add to current datafile=0A=
if [ -z "$1" ]=0A=
then=0A=
  HR=3D`date +%H`=0A=
  vmoprcmd -d ds | awk '$1~/^[0-9]/ {if ($3~/DOWN/) {print =
'$HR',$1,"D"} else {=0A=
                                   if ($3~/PEND/) {print '$HR',$1,"P"} =
else {=0A=
                                   if ($3~/AVR/)  {print '$HR',$1,"A"} =
else {=0A=
                                   if ($NF=3D=3D"-")  {print =
'$HR',$1,"-"} else {=0A=
                                   print '$HR',$1,"#"}}}}}' >>$DFILE=0A=
fi=0A=
exit=0A=

------_=_NextPart_000_01C43D27.FB3E672A--

<Prev in Thread] Current Thread [Next in Thread>
  • [Veritas-bu] Graphing Drive Usage, Mark.Donaldson AT cexp DOT com <=