⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 table_map1.sh.txt

📁 管理online的shell程序
💻 TXT
字号:
#!/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.outPAGESIZE=2XDATE=`date +%D-%T`BG=falseclsecho "Report on physical location of a table (which chunk)"while truedo        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!"        echodonecase $OPTION1 in 	1) TABLENAME=FLAG_ALL_TABLES;;	2) echo	   echo "Enter table name to report on"	   read TABLENAME	   ;;	3) exit;;esacwhile truedo	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!"	echodone        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;;esacwhile truedo        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;; esacdoneif [ $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 (<Enter> 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        fiif [ -f $OUTPUT ]then        rm -f $OUTPUTfi################################################################################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 BEGINNINGBEGIN {    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 > $OUTPUTecho echo "Working - pass 2..."echo echo >> $OUTPUTecho "------------------------- Chunk Summary -------------------------">> $OUTPUTecho >> $OUTPUTcat $INPUT |awk ' /Chunk:/ {                      chunk=$2        addr=$3        printf "Chunk: %3s  %s\n",chunk, addr}' | sort -n -u +1 >> $OUTPUTif [ $BG = false ]then        pg $OUTPUTfiechoecho "Note: Output report is in $OUTPUT"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -