#!/usr/bin/bash

. ./stub.sh
ver=$1

if [ “${ver:=x}” = “-v” ]
then
ver_info
exit 0
fi

while :
do
clear
sqlplus -s ‘/ as sysdba’ << eof | grep -v ^$
set lines 100
set pages 60
set feedback off
set head off
column CMD format a35 heading ‘Command’
column STT format a20 heading ‘Start Time’
column SOFAR format 9,999,999,999 heading ‘Completed Wrk’
column TOTWRK format 9,999,999,999 heading ‘Total Wrk’
column PCT format 999 heading ‘%’
column END format a8 heading ‘End Est.’
select to_char(sysdate, ‘DD-MON-YY HH24:MI:SS’) from dual;
set head on
Select to_char(start_time, ‘DD-MON-YY HH24:MI:SS’) STT,
sofar SOFAR,
totalwork TOTWRK,
sofar/totalwork * 100 PCT,
to_char(sysdate + (time_remaining/24/60/60),’HH24:MI’) End,
opname CMD
From v\$session_longops
where sofar/totalwork * 100 < 100
and totalwork > 0
order by 5;

–column “AVG CR BLOCK RECEIVE TIME (ms)” format 9999999.9
–select b1.inst_id, b2.value “GCS CR BLOCKS RECEIVED”,
–b1.value “GCS CR BLOCK RECEIVE TIME”,
–((b1.value / b2.value) * 10) “AVG CR BLOCK RECEIVE TIME (ms)”
–from gv\$sysstat b1, gv\$sysstat b2
–where b1.name = ‘global cache cr block receive time’ and
–b2.name = ‘global cache cr blocks received’ and b1.inst_id = b2.inst_id ;
eof
sleep 15
done