Veritas-bu

[Veritas-bu] script to show usage of tape drives on a media s erver

2005-04-13 13:36:12
Subject: [Veritas-bu] script to show usage of tape drives on a media s erver
From: Mark.Donaldson AT cexp DOT com (Mark.Donaldson AT cexp DOT com)
Date: Wed, 13 Apr 2005 11:36:12 -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_01C5404F.49686E45
Content-Type: text/plain;
        charset="iso-8859-1"

This is my script for this - it does graph, in fact.  Just run it via cron
every 15 min or so (mine is cron'd for "1,16,31,46 * * * *").  

Other than adding your email address to the "ADDR" variable at the top of
the script, it's self configuring.  More frequent runs gives better
resolution but wider graphs (and the reverse, of course).  It mails the
graph at midnight when the collection file rolls over.

At the bottom, it gives percentage of availability by drive & overall.

Note, if a job starts & ends between sample periods, it's missed.  The
output is purely based on samples.  Once day I'll work out a log scraper
that parses the bptm file but that's far away.  

-M

-----Original Message-----
From: veritas-bu-admin AT mailman.eng.auburn DOT edu
[mailto:veritas-bu-admin AT mailman.eng.auburn DOT edu]On Behalf Of Benton, 
Daniel
Sent: Wednesday, April 13, 2005 9:40 AM
To: veritas-bu AT mailman.eng.auburn DOT edu
Subject: [Veritas-bu] script to show usage of tape drives on a media server


I'm trying to find a script that will show the amount of time each tape
drive on a media server is used during the day.
I don't need any graphic - just the tape drive name and the amount of time
in use.
 
Thanks,
 


------_=_NextPart_000_01C5404F.49686E45
Content-Type: application/octet-stream;
        name="drive_graph.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="drive_graph.sh"

#!/bin/ksh=0A=
=0A=
ADDR=3D"YOU AT YOURDOMAIN DOT COM"=0A=
=0A=
PATH=3D$PATH:/usr/openv/volmgr/bin=0A=
PROGNAME=3D`basename $0`=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=
    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=
    #Availability Calcs=0A=
    GDA=3D`awk 'BEGIN {sample=3D0;up=3D0}=0A=
         { sample++ ; if ($3=3D=3D"-") {up++}}=0A=
         END {printf ("%3.1f",up/sample*100)}' $lastfile`=0A=
=0A=
    echo "\n## Drive Availability: ${GDA}%" =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 "NB Rpt: 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_01C5404F.49686E45--

<Prev in Thread] Current Thread [Next in Thread>