#!/usr/bin/ksh #set -x # author : B. Polarski # program : smenu_session_wait.sh # HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` SBINS=$SBIN/scripts # ----------------------------------------------------------------- function help { cat < SEQ# : The internal sequence number of the wait for this session. ------ Use this column to determine the number of waits (counts), the session has experienced P[1-3] These parameters are foreign keys to other views and are wait event dependent ------ for latch waits, P2 is the latch number, which is a foreign key to v\$latch for 'db file sequential read' or 'db file scattered read' P1 is the file number (foreign key to v\$filestat or dba_data_files) and P2 is the actual block number (related to dba_extents, sys.uet\$) STATE : WAITING = Session is currently waiting for event. See 'SECONDS_IN_WAIT' for value in secds. WAITED UNKNOWN TIME= Timed statistics = false! WAITED SHORT TIME : Session did not wait even one clock tick, no wait recorded WAITING KNOW TIME : Wait time was recorded. See 'WAIT_TIME' for value in secds. WAIT_TIME: The values of WAIT_TIME are : Negative : the wait time was unknown. Zero : the session is still waiting. Positive : the session's last wait time. A zero value means the session is currently waiting. EOF exit } # ----------------------------------------------------------------- while [ -n "$1" ] do case "$1" in -r ) RAC=TRUE;; -k ) J_DISP=TRUE;; -p ) TANEL=TRUE;; -t ) WST=TRUE ;; -h ) help exit;; * ) AND_SID=" and sid = '$1' " esac shift done . $SBIN/scripts/passwd.env . ${GET_PASSWD} $S_USER $ORACLE_SID if [ "x-$CONNECT_STRING" = "x-" ];then echo "could no get a the password of $S_USER" exit 0 fi if [ "$WST" = "TRUE" ];then echo echo $NN "MACHINE $HOST - ORACLE_SID : $ORACLE_SID $NC" sqlplus -s "$CONNECT_STRING" < 0 order by nvl(t0, 0) + nvl(t1, 0) + nvl(t2, 0) + nvl(t3, 0) + nvl(t4, 0) + nvl(t5, 0) + nvl(t6, 0) + nvl(t7, 0) + nvl(t8, 0) + nvl(t9, 0) / prompt prompt EOF elif [ "$TANEL" = "TRUE" ];then #-------------------------------------------------------------------------------- #-- #-- Purpose: Display current Session Wait info #-- Author: Tanel Poder #-- Copyright: (c) http://www.tanelpoder.com #-- Usage: @sw #-- @sw 52,110,225 #-- @sw "select sid from v$session where username = 'XYZ'" #-- @sw &mysid #-- #-------------------------------------------------------------------------------- sqlplus -s "$CONNECT_STRING" < 0 ORDER BY seconds desc / EOF elif [ "$J_DISP" = "TRUE" ];then # This is "John Kanagaraj" approach. I don't can't say it is really superior. (bp) # more over the decode can show a session in (C) while the status is already inactive. sqlplus -s "$CONNECT_STRING" < 0 $AND_SID $ORDER / prompt EOF fi