Veritas-bu

[Veritas-bu] Korn Scripts to Perl Conversion

2000-10-20 13:04:36
Subject: [Veritas-bu] Korn Scripts to Perl Conversion
From: Keahey, Ricky L ricky.l.keahey AT intel DOT com
Date: Fri, 20 Oct 2000 10:04:36 -0700
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_01C03AB7.D38CA550
Content-Type: text/plain;
        charset="ISO-8859-1"

I have a script that I got from someone on here that I would like to see if
it could be converted to Perl easily.  If it can't, does anyone have a perl
script that will allow the master to look in all of the volume pools for
available media and move it to the scratch pool if it is found?  Here is a
copy of the script if anyone can convert it. Thanks for any help on this
one.

 <<scratch_pop.ksh>> 

Thanks,
Rick Keahey
Enterprise Storage Utility
Intel Corp.


------_=_NextPart_000_01C03AB7.D38CA550
Content-Type: application/octet-stream;
        name="scratch_pop.ksh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="scratch_pop.ksh"

#!/bin/ksh=0A=
#=0A=
# scratch_populator.ksh=0A=
# Rob Worman, Collective Technologies, rob AT colltech DOT com=0A=
# 9/14/2000=0A=
#=0A=
# this script looks for AVAILABLE media that is not a part=0A=
# of the scratch pool, and moves any media it finds into the=0A=
# scratch pool. this script should be run from root's crontab=0A=
# on the NetBackup master server.=0A=
#=0A=
#set -x=0A=
#=0A=
=0A=
Usage() {=0A=
        echo "Usage: $0 [-n] [-i <pool>] "=0A=
        echo "This program will automatically checks for AVAILABLE"=0A=
        echo "media in the library that is not in the scratch pool."=0A=
        echo "If any such media is found, it is moved into the"=0A=
        echo "scratch pool."=0A=
        echo=0A=
        echo "-n flag only gives debug info on what the script"=0A=
        echo "WOULD do, no changes are actually made."=0A=
        echo=0A=
        echo "-i specifies the name of a pool that should"=0A=
        echo " be ignored (i.e. a pool that is intended"=0A=
        echo "to have some AVAILABLE tapes, like the"=0A=
        echo "NBU DB backup pool if you are using bpvault.)"=0A=
        echo=0A=
}=0A=
=0A=
=0A=
# parse the arguments=0A=
while getopts :ni: option=0A=
do=0A=
    case $option in=0A=
       "n" ) DEBUG=3D"true"=0A=
             ;;=0A=
       "i" ) IGNOREPOOL=3D"${OPTARG}"=0A=
             ;;=0A=
       "?") echo "bad option"=0A=
                Usage=0A=
                exit 1=0A=
             ;;=0A=
    esac=0A=
done=0A=
=0A=
SCRATCHPOOL=3D`egrep '^SCRATCH_POOL' /usr/openv/volmgr/vm.conf | cut =
-f3 -d" "`=0A=
VMQUERY=3D/usr/openv/volmgr/bin/vmquery=0A=
VMPOOL=3D/usr/openv/volmgr/bin/vmpool=0A=
VMCHANGE=3D/usr/openv/volmgr/bin/vmchange=0A=
BPMEDIALIST=3D/usr/openv/netbackup/bin/admincmd/bpmedialist=0A=
=0A=
#determine the pool number of the scratch pool=0A=
SCRATCHPOOL_NUM=3D`$VMPOOL -listall \=0A=
        |awk '$0 ~ /pool number/ { printf $0 } $0 ~ /pool name/ { print =
$0 }' \=0A=
        |grep $SCRATCHPOOL|sed 's/pool name.*//'|sed 's/.* //'`=0A=
=0A=
#basic error checking=0A=
if [ -f /usr/openv/netbackup/version ]=0A=
then=0A=
        HARDWARE=3D`head -1 /usr/openv/netbackup/version | cut -f2 -d" "`=0A=
else=0A=
        echo "/usr/openv/netbackup/version not found!"=0A=
        exit 1=0A=
fi=0A=
=0A=
#basic error checking=0A=
if [ X$SCRATCHPOOL =3D X ]=0A=
then=0A=
        echo "no scratch pool defined in /usr/openv/volmgr/vm.conf!"=0A=
        exit 1=0A=
fi=0A=
=0A=
# a little bit debugging output, if desired        =0A=
if [ $DEBUG ]=0A=
then=0A=
  echo "--- debug output:"=0A=
  echo "--- scratch pool is $SCRATCHPOOL, which is pool number =
$SCRATCHPOOL_NUM"=0A=
  if [ -n $IGNOREPOOL ]=0A=
  then=0A=
     echo "--- ignoring pool $IGNOREPOOL"=0A=
  fi=0A=
  echo "--- the following commands would be executed next:"=0A=
fi=0A=
=0A=
# getting down to it...=0A=
#=0A=
VMQUERY=3D/usr/openv/volmgr/bin/vmquery=0A=
VMPOOL=3D/usr/openv/volmgr/bin/vmpool=0A=
=0A=
VMPOOL_OUTPUT=3D/tmp/vmpool_output=0A=
/bin/rm -rf $VMPOOL_OUTPUT=0A=
touch $VMPOOL_OUTPUT=0A=
=0A=
$VMPOOL -listall -b 2>/dev/null | tail +3 | sort +0 1>$VMPOOL_OUTPUT =
2>/dev/null=0A=
=0A=
VMQUERY_OUTPUT=3D/tmp/vmquery.out=0A=
=0A=
cat $VMPOOL_OUTPUT |=0A=
while read poolname poolhost pooluser poolgroup pooldesc=0A=
do=0A=
        /bin/rm -rf $VMQUERY_OUTPUT=0A=
        touch $VMQUERY_OUTPUT=0A=
        $VMQUERY -pn $poolname -bx 2>/dev/null | tail +4 1>>$VMQUERY_OUTPUT =
2>/dev/null=0A=
=0A=
        cat $VMQUERY_OUTPUT |=0A=
        while read vmediaid vmediatype vrobottype vrobotnum vrobotslot vside =
vvol vop vmnts vlmtdate vlmttime vasgndate vasgntime vpool =0A=
        do=0A=
=0A=
        if [ "${vasgndate}" =3D "---" -a "${vasgntime}" =3D "---" -a =
"${poolname}" !=3D "${SCRATCHPOOL}" -a "${vmediatype}" !=3D "DLT_CLN" =
-a "${poolname}" !=3D "${IGNOREPOOL}" ]=0A=
                then=0A=
                        =0A=
                        # move this media into the scratch pool,=0A=
                        # unless DEBUG is set, in which case we=0A=
                        # only echo the command=0A=
                        if [ ! $DEBUG ]=0A=
                        then=0A=
                                $VMCHANGE -p $SCRATCHPOOL_NUM -m $vmediaid=0A=
                        else=0A=
                           echo "$VMCHANGE -p $SCRATCHPOOL_NUM -m $vmediaid"=0A=
                        fi=0A=
        fi=0A=
        done=0A=
done=0A=

------_=_NextPart_000_01C03AB7.D38CA550--




<Prev in Thread] Current Thread [Next in Thread>
  • [Veritas-bu] Korn Scripts to Perl Conversion, Keahey , Ricky L ricky . l . keahey <=