Verificar sessões e waits Oracle Database

select
   a.inst_id as inst,
   substr(a.spid,1,5) pid,
   b.sid||','||b.serial# as sid_serial,
   status, 
   substr(b.machine,1,25) box,
   substr(b.username,1,10) username,
   substr(b.osuser,1,30) os_user,
   substr(sw.event,1,30) event,
   sw.wait_class,
   sw.seconds_in_wait waiting,
   b.server,
   decode(b.program,null,substr(a.program,1,30),substr(b.program,1,30)) program,
   TO_CHAR(LOGON_TIME, 'DD/MM/YYYY HH24:MI:SS' ) LOGON_TIME,
             CASE  
        WHEN LAST_CALL_ET< 60 THEN LAST_CALL_ET || ' Seconds'
        WHEN LAST_CALL_ET< 3600 THEN ROUND(LAST_CALL_ET/60) || ' Minutes'
        WHEN LAST_CALL_ET< 86400 THEN ROUND(LAST_CALL_ET/60/60,1) || ' Hour(s)'
      ELSE
        ROUND(LAST_CALL_ET/60/60/24,1) || ' Day(s)'
     END INACTIVE_ACTIVE_TIME,
   b.sql_id,
       optimizer_mode,
       hash_value,
       sql_text,
     'ALTER SYSTEM DISCONNECT SESSION ' || CHR(39) || b.sid || ',' || b.serial# || ',@' || a.INST_ID || chr(39) || ' immediate;' kill_cmd
from
   gv$session b,
   gv$process a,
   gv$session_wait sw,
   gv$sqlarea sqlarea
where b.paddr = a.addr
      and b.inst_id = a.inst_id
      and type='USER'
    and sw.inst_id = b.inst_id
    and sw.sid = b.sid
    and b.sql_hash_value = sqlarea.hash_value
      and b.sql_address    = sqlarea.address
     and sw.event not in ('ges remote message','gcs remote message','rdbms ipc message',
                            'SQL*Net message from client','SQL*Net message to client',
                            'events in waitclass Other','DIAG idle wait','SQL*Net more data from client',
                            'PX Deq: Execute Reply','PX Deq: Join ACK','PX Deq: Parse Reply',
                            'Streams AQ: waiting for messages in the queue','wait for unread message on broadcast channel',
                            'jobq slave wait','SQL*Net message from dblink','PX Deq: Execution Msg')
    and TYPE != 'BACKGROUND'
order by status, spid;
ShellScript

Leave a Reply

Your email address will not be published. Required fields are marked *

search previous next tag category expand menu location phone mail time cart zoom edit close