« March 29, 2006 | Main | May 27, 2006 »

May 16, 2006 Archives

May 16, 2006

Check Waits Script

This script provides a quick view of the wait events in the database.
Is ready to be run on Unix or Linux
Usage: chkwait <sid>
review the variables section to customize it for your environment.

==== script start on next line ====
#!/usr/bin/ksh
# set -x (open for dubuging)
# lib_cache_fast
# This script check main waits.
# Variables required = 1, Oracle SID
# External identified DBA user required
# Alejandro Vargas

# Check Input Variables
# ---------------------

if [ $# -lt 1 ]; then
   clear
   echo
   echo $0 check waits on a database,
   echo
   echo Please enter Oracle SID to connect to.
   echo
   exit
fi

# Variables
# ---------

v_ld=/tmp/scripts                              
# Local Directory
v_lg=$v_ld/logs                                
# Log Directory
v_x1=`cat
$v_ld/.151762`                       
# no description available
v_ts=`date
+%d%m%Y%H%M`                        
# Time Stamp
v_sd=$1                                        
# Oracle Sid to run on
v_ns=`echo $v_sd | tr '[a-z]' '[A-Z]'`          # Capitalized Oracle Sid

cd $v_ld
export v_ts

# Execute sqlplus
# ---------------

sqlplus -s /@$v_sd <<eof1
set pages 10000 lines 100
col sid for 9999
col event for a30
col name for a45
col p1raw for a15
col p1 for 99999999999
col p2 for 9999999999
col p3 for 9999999999
col seq# for 9999999
col wait_time for 9999

spool $v_lg/$0.$v_ns.log
select sysdate from dual;

prompt * Sessions with wait_time <> 0 (only wait_time=0 is waiting now)

select sid,event,p1,p2,p3,seq#,wait_time
from v$session_wait where event not like 'SQL*Net%'
and wait_time<>0
order by 2
/

prompt * Sessions Waiting Now

select sid,event,p1,p2,p3,seq#,wait_time
from v$session_wait where event not like 'SQL*Net%'
and  wait_time=0
order by 2
/

prompt * Total Main Waits

select count(*),event
from v$session_wait where event not like 'SQL*Net%'
group by event
order by 1
/

prompt * Sessions waiting now

select count(*),event
from v$session_wait where event not like 'SQL*Net%'
and wait_time=0
group by event
order by 1
/

prompt * Latches been waited for

select  *
from    v$latchname
WHERE   latch# in (select unique p2
                 
from  v$session_wait
                 
where event ='latch free')
/

prompt * Latch children

select  addr,
        latch#,
        gets,
        misses,
        sleeps
FROM    v$latch_children
WHERE   sleeps>0
and     latch# in (select unique p2
                 
from  v$session_wait
                 
where event ='latch free')
ORDER   BY sleeps
/

prompt * Latches Waits

SELECT  latch#,
        name,
        gets,
        misses,
        sleeps
FROM    v$latch
WHERE   sleeps>0
ORDER   BY misses, sleeps
/

spool off
exit
eof1

clear
more  $v_lg/$0.$v_ns.log

# eof chkwait
===== script finish on previous line =====

RAC, Performance Issues and Hangs

Performance Issues and Hangs



Is the problem due to a slow/hung query or is the entire database affected?  Try running the following SQL statement in SQL*Plus: 



select inst_id, sid, state, event, seconds_in_wait seconds



from gv$session_wait



where seconds_in_wait > 5



and event not in ('rdbms ipc message','smon timer','pmon timer',



'SQL*Net message from client','lock manager wait for remote message',



'ges remote message', 'client message', 'SQL*Net more data from client',



'pipe get', 'Null event', 'PX Idle Wait', 'single-task message',



'PX Deq: Execution Msg', 'KXFQ: kxfqdeq - normal deqeue', 'listen endpoint status',



'slave wait','wakeup time manager');



If the query does not return, you may have a hung database.



If the query returns no rows, you may have database performance issues.



If the query returns rows, you may have hung sessions.

Checkup Reserved Size Usage

Checkup Reserved Size Usage

This check require 3 steps:

1) create a table to gather the reserved size statistics:

drop table v_reserved_size_history;
create table v_reserved_size_history(
 TIMESTAMC       DATE,
 FREE_SPACE      NUMBER,
 AVG_FREE_SIZE   NUMBER,
 FREE_COUNT      NUMBER,
 MAX_FREE_SIZE   NUMBER,
 USED_SPACE      NUMBER,
 AVG_USED_SIZE   NUMBER,
 USED_COUNT      NUMBER,
 MAX_USED_SIZE   NUMBER,
 REQUESTS        NUMBER,
 REQUEST_MISSES  NUMBER,
 LAST_MISS_SIZE  NUMBER,
 MAX_MISS_SIZE   NUMBER,
 REQUEST_FAILURES  NUMBER,
 LAST_FAILURE_SIZE NUMBER,
 ABORTED_REQUEST_THRESHOLD  NUMBER,
 ABORTED_REQUESTS  NUMBER,
 LAST_ABORTED_SIZE NUMBER
)
tablespace tbs_monitor
/


2) Execute a script to populate it every 5 minutes:

#!/usr/bin/ksh
# set -x
# chkressize
# This script insert records to check for reserved size variations
# and generate a report
# Alejandro

. /jinn/app01/oracle/scripts/cshrc/817/.profile
td=/jinn/app01/oracle/scripts/av/freezedb/chkressizes
to=statgather
ts=`date +%d%m%Y%H%M`
cd $td
export ts
sid=$1
newsid=`echo $sid | tr '[a-z]' '[A-Z]'`
sqlplus -s /@dbaprod <<eof1

insert into $to.V_RESERVED_SIZE_HISTORIES
select
 SYSDATE                        ,
 '$sid'                         ,
 FREE_SPACE                     ,
 AVG_FREE_SIZE                  ,
 FREE_COUNT                     ,
 MAX_FREE_SIZE                  ,
 USED_SPACE                     ,
 AVG_USED_SIZE                  ,
 USED_COUNT                     ,
 MAX_USED_SIZE                  ,
 REQUESTS                       ,
 REQUEST_MISSES                 ,
 LAST_MISS_SIZE                 ,
 MAX_MISS_SIZE                  ,
 REQUEST_FAILURES               ,
 LAST_FAILURE_SIZE              ,
 ABORTED_REQUEST_THRESHOLD      ,
 ABORTED_REQUESTS               ,
 LAST_ABORTED_SIZE
from v$shared_pool_reserved@$sid
/
col freespc for 999999999
col avgfree for 9999999
col maxfree for 9999999
col used for 999999999
col avgused for 9999999
col requests for 99999999
col failures for 99999999
col lstfailsz for 999999
col misses for 999999
col lstmisssz for 99999
col maxmisssz for 9999

set pages 50000 lines 100 echo off veri off
spool $td/$newsid.reserved_size.log

SELECT
        to_char(timestamc,'dd/mm hh24:mi') collect_date,
        free_space freespc,
--      avg_free_size avgfree,
        max_free_size maxfree,
        used_space used,
        avg_used_size avgused,
        requests,
        request_failures failures,
        last_failure_size lstfailsz,
        request_misses misses,
        last_miss_size lstmisssz
--      max_miss_size maxmisssz
FROM    $to.v_reserved_size_histories  -- v$shared_pool_reserved
where   timestamc  >= trunc(sysdate)
and     dbname='$sid'
/
spool off
exit
eof1

v_chk=`cat $newsid.reserved_size.log | grep : | tail -1 | awk '{print $8}'`
if [ $v_chk -gt 1 ]; then
 echo Failures to allocate segments on reserved area = $v_chk, Please check.
 msg='$newsid $v_chk Failures to allocate segments on reserved area'
 sendsms $msg
fi

# eof chkressize

3) use a script to check the statistics when required:

#!/usr/bin/ksh
# set -x
# chkreserved
# This script check reserved size behaviour
# Alejandro

. /jinn/app01/oracle/scripts/cshrc/817/.profile
cd /jinn/app01/oracle/scripts/av/freezedb/reserved_sizes
x1=`cat ../.151762`
ts=`date +%d%m%Y%H%M`
export ts
sid=$1
newsid=`echo $sid | tr '[a-z]' '[A-Z]'`
sqlplus -s sys/$x1@$sid <<eof1
set pages 100 lines 100

col freespc for 999999999
col avgfree for 9999999
col maxfree for 9999999
col used for 999999999
col avgused for 9999999
col requests for 99999999
col failures for 99999999
col lstfailsz for 999999
col misses for 999999
col lstmisssz for 99999
col maxmisssz for 9999

spool $newsid.reserved_size.$ts
spool $newsid.reserved_size.$ts
select  x.ksppinm||'='||y.ksppstvl PARAMETERS
from    x$ksppi        x,
        x$ksppcv       y
where   x.indx = y.indx
and     x.ksppinm like '%reserved%'
/

SELECT
        to_char(timestamc,'dd/mm hh24:mi') collect_date,
        free_space freespc,
--      avg_free_size avgfree,
        max_free_size maxfree,
        used_space used,
        avg_used_size avgused,
        requests,
        request_failures failures,
        last_failure_size lstfailsz,
        request_misses misses,
        last_miss_size lstmisssz
--      max_miss_size maxmisssz
FROM    ops$oracle.v_reserved_size_history  -- v$shared_pool_reserved
where   timestamc  >=   sysdate -7 -- trunc(sysdate)
/

select STARTUP_TIME from v$instance
/
spool off
exit
eof1
# eof chkreserved

About May 2006

This page contains all entries posted to Alejandro Vargas' Blog in May 2006. They are listed from oldest to newest.

March 29, 2006 is the previous archive.

May 27, 2006 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle