Svenson's  Bulletin Board Forum Index Svenson's Bulletin Board
Bulletin Board for boat building and model airplane building enthusiasts.
 
AlbumAlbum   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

script to create alter tablespace stment with add containers

 
Post new topic   Reply to topic    Svenson's Bulletin Board Forum Index -> DB2
View previous topic :: View next topic  
Author Message
craig
Site Admin


Joined: 19 Feb 2006
Posts: 40

PostPosted: Thu Nov 02, 2006 3:33 pm    Post subject: script to create alter tablespace stment with add containers Reply with quote

#!/bin/ksh

Spindles()
{
df -k | \
grep dasd | \
egrep -v 'log|100%|9[0-9]%' | \
sort +3 -n | \
awk '{ print $7 }'
}

Showvar()
{
eval echo $1=$"$1"
}

ShowTheContainerInfo()
{
Showvar ContainerID
Showvar Name
Showvar Type
Showvar Totalpages
Showvar Useablepages
Showvar Accessible
}

ShowTheTablespaceInfo()
{
Showvar TablespaceID
Showvar Name
Showvar Type
Showvar Contents
Showvar State
Showvar Totalpages
Showvar Useablepages
Showvar Usedpages
Showvar Freepages
Showvar Highwatermarkpages
Showvar Pagesizebytes
Showvar Extentsizepages
Showvar Prefetchsizepages
Showvar Numberofcontainers
Showvar Minimumrecoverytime
}

ListContainer()
{
DEL=""
[ $Numberofcontainers -ne $cont ] && DEL=","

# ShowTheContainerInfo
if [ $Type = "File" ] ; then
echo " -- $Type '$Name' $Totalpages$DEL"
else
echo " -- $Type '$Name'$DEL"
fi
}

GetContainers()
{
PCT=$(echo $Freepages $Totalpages | \
awk '{ A=($1/$2) ; printf("%2.0f", A*100.0) }' )
PPC=$(echo $Totalpages $Numberofcontainers | \
awk '{ A=($1/$2) ; printf("%2.0f", A) }' )
ADD=$(echo $Totalpages | \
awk '{ A=($1 * .2) ; printf("%2.0f", A) }' )

[ $PCT -ge 21 ] && return

# ShowTheTablespaceInfo

# echo $Name $PPC $Numberofcontainers $PCT

TS_Name=$Name

echo "alter tablespace $TS_Name add ("
let cont=0

DISK=$(Spindles | head -1)

db2 list tablespace containers for $TablespaceID show detail | \
grep = | \
sed 's/[ ()]//g' | \
sed 's/=/ /' | \
while read VR VL
do
eval "export $VR=$VL"
[ $VR = "Accessible" ] && {
let cont+=1
ListContainer
}
done

let cont+=1

if [ $Type = "File" ] ; then
echo " $Type '$DISK/$DB.$TS_Name.container.$cont' $Totalpages"
else
# echo " $Type '$DISK/$DB.$TS_Name.path.$cont'"
set l=1
fi
echo ");\n"
}


DB=DEVDW_4

db2 -o- connect to $DB
echo "connect to $DB;"

db2 list tablespaces show detail | \
grep = | \
sed 's/[ ()]//g' | \
sed 's/=/ /' | \
while read VAR VAL
do
[ $VAR = "Freepages" -a $VAL = "Notapplicable" ] && continue
[ $VAR = "Type" -a $VAL != "Databasemanagedspace" ] && continue
eval "export $VAR=$VAL"
[ $VAR = "Minimumrecoverytime" ] && GetContainers
done

exit 0
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Svenson's Bulletin Board Forum Index -> DB2 All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group