#!/usr/bin/ksh ############################################################################### # # Module: table_map1.sh # Author: Peter R. Schmidt # Description: Report on the physical location of a table (which chunk) # for an online engine database # # Change Log # # Date Name Description................. # 06/13/96 Peter R. Schmidt Start Program # ############################################################################### OUTPUT=table_map1.out PAGESIZE=2 XDATE=`date +%D-%T` BG=false cls echo "Report on physical location of a table (which chunk)" while true do echo echo "1 = All Tables" echo "2 = Report on a single table" echo "0 = Exit this program" echo echo "Enter sort sequence desired (0,1,2)" read OPTION1 case $OPTION1 in 0|1|2) break;; esac echo echo "Error - you must enter 0, 1, or 2!" echo done case $OPTION1 in 1) TABLENAME=FLAG_ALL_TABLES;; 2) echo echo "Enter table name to report on" read TABLENAME ;; 3) exit;; esac while true do echo echo "1 = Report in Megs" echo "2 = Report in Kbytes" echo "3 = Report in Pages" echo "4 = Report in Bytes" echo "0 = Exit this program" echo echo "Enter reporting unit desired (0,1,2,3,4)" read OPTION2 case $OPTION2 in 0|1|2|3|4) break;; esac echo echo "Error - you must enter 0,1,2,3 or 4!" echo done case $OPTION2 in 0) echo "End requested by user"; exit;; 1) UNIT=M; UNITDESC=Mbytes;; 2) UNIT=K; UNITDESC=Kbytes;; 3) UNIT=P; UNITDESC=Pages;; 4) UNIT=B; UNITDESC=Bytes;; esac while true do echo echo "Note: oncheck -pe must be run for this program to work." echo echo "Have you run 'oncheck -pe' and saved the output to a file yet? (y/n) " echo echo "Note: if 'n', I will run oncheck -pe for you." echo " if 'y', I will ask you the filename containing the output of oncheck -pe." echo read answer case $answer in Y|y|N|n) break;; esac done if [ $answer = N -o $answer = n ] then echo "Running oncheck -pe (saving output in check_pe.out)..." oncheck -pe > check_pe.out INPUT="check_pe.out" else while true do echo echo "Enter name of file containing output of oncheck -pe ( for default of 'pe.out')" read INPUT if [ "x$INPUT" = "x" ] then INPUT=pe.out fi if [ ! -f $INPUT ] then echo "Error: file $INPUT does not exist!" exit 1 fi break done fi if [ -f $OUTPUT ] then rm -f $OUTPUT fi ################################################################################ echo echo "Working - pass 1..." awk ' /Chunk:/ { chunk=$3 } /:/ { if (/DBspace Usage Report:/) { continue } if (/Size Used Free/) { continue } split ($1,a,".") table=a[2] split ($1,a,":") database=a[1] start=$2 size_P=$3 if (tablename != "FLAG_ALL_TABLES") { if (tablename != table) { continue } } size_K=size_P*pagesize size_M=size_K/1024 size_B=size_K*1024 if (unit == "B") { printf "%-15s %-15s %10.2f %s\n",database, table, size_B, chunk } if (unit == "P") { printf "%-15s %-15s %10d %s\n",database, table, size_P, chunk } if (unit == "K") { printf "%-15s %-15s %10d %s\n",database, table, size_K, chunk } if (unit == "M") { printf "%-15s %-15s %10d %s\n",database, table, size_M, chunk } } ' \ tablename=$TABLENAME \ unit=$UNIT \ unitdesc=$UNITDESC \ pagesize=$PAGESIZE \ $INPUT | sort -n | awk ' ############################################################################### # INITIALIZE VARIABLES AT BEGINNING BEGIN { cntline=5 pageno=1 } ############################################################################### # FIRST LINE ONLY { if (NR == 1) { split (xdate,b,"-") udate=b[1] utime=b[2] printf "%s %s Informix Table Disk Map Page: %d\n", udate, utime, pageno printf "\n" printf " Size in \n" printf "Database Table %7s Chunk \n", unitdesc printf "\n" } } ############################################################################### # ON EVERY LINE { print cntline++ } ############################################################################### # TOP OF PAGE { if (cntline == 60) { pageno++ printf "\f\n" printf "%s %s Informix Table Disk Map Page: %d\n", udate, utime, pageno printf "\n" printf " Size in \n" printf "Database Table %7s Chunk \n", unitdesc printf "\n" cntline=5 } } ' unit=$UNIT unitdesc=$UNITDESC xdate=$XDATE > $OUTPUT echo echo "Working - pass 2..." echo echo >> $OUTPUT echo "------------------------- Chunk Summary -------------------------">> $OUTPUT echo >> $OUTPUT cat $INPUT | awk ' /Chunk:/ { chunk=$2 addr=$3 printf "Chunk: %3s %s\n",chunk, addr } ' | sort -n -u +1 >> $OUTPUT if [ $BG = false ] then pg $OUTPUT fi echo echo "Note: Output report is in $OUTPUT"