#!/usr/bin/ksh # set -x function help { cat < : Count occurence of same type of SQL (not using bind variable Len is the length of SQL string to scan. Default is 40 sqn -l : to change sql text length to display sqn -u : limit to user Sort options : -t : text -b : buffer_gets -x : executions -e : elapsed -c : cpu -o : optimizer cost -d : disk reads -dw : direct write -hv : show hash_value -v : verbose -r : limit to rows EOF } SILENCE=N OWNER= ROWNUM=30 LEN=60 COUNT_LEN=40 METHOD=DEFAULT typeset -u UPPVAR VAR_FIELDS="c.buffer_gets, c.buffer_gets/decode(c.executions,0,1,c.executions) xbuffer_gets, users_opening" VAR_FIELDS1="buffer_gets, buffer_gets/decode(executions,0,1,executions) xbuffer_gets, users_opening" ORDER=" order by last_active_time desc" FTIME=cpu_time while true do if [ -z "$1" ];then break fi case $1 in -b ) ORDER=" ORDER by buffer_gets desc" ;; -c ) ORDER=" ORDER by cpu_time desc" ;; -cpt ) METHOD=COUNT ;; -dw ) ORDER=' ORDER by direct_writes desc' ; VAR_FIELDS="disk_reads,direct_writes," ; VAR_FIELDS1="disk_reads,direct_writes," ;; -d ) ORDER=" ORDER by disk_reads desc" VAR_FIELDS="disk_reads,disk_reads/decode(executions,0,1,executions) xdisk, direct_writes" ; VAR_FIELDS1="disk_reads,disk_reads/decode(executions,0,1,executions) xdisk,direct_writes" ;; -e ) ORDER=" ORDER by elapsed_time desc" ; FTIME=elapsed_time ;; -hv ) HASH_VALUE=" HASH_VALUE, " ;; -l|len ) COUNT_LEN=$2 ; shift ;; -o ) ORDER=" and optimizer_cost is not null ORDER by optimizer_cost desc" ;; -t ) ORDER=" ORDER by text " ;; -u ) UPPVAR=$2 ; F_USER=" and parsing_schema_name = upper('$UPPVAR') " ; shift ;; -rac ) G=G ;; -x ) ORDER=" ORDER by executions desc" ;; -v ) VERBOSE=TRUE;; -rn ) ROWNUM=$2 ; shift ;; -h ) help exit ;; esac shift done if [ -n "$HASH_VALUE" ];then LEN=`expr $LEN - 9` fi HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` SBINS=$SBIN/scripts . $SBIN/scripts/passwd.env . ${GET_PASSWD} if [ "x-$CONNECT_STRING" = "x-" ];then echo "could no get a the password of $S_USER" exit 0 fi RET=`sqlplus -s "$CONNECT_STRING" <