Question: I want
to generate an AWR report during the period of peak CPU
usage. How can I have a script to generate an AWR
report during periods of peak CPU usage.
Answer: The following script will
find the period of peak CPU usage and generate the syntax to
create an AWR report for that snapshot period.
ading off
set feedback off
spool runme.sql
select 'spool awr_rpt.txt' from dual;
with
sum_awr
as
(
select
snapshot c1,
to_char(snaptime, 'yyyy-mm-dd hh24') c2,
to_number(round(busydelta / (busydelta + idledelta) * 100, 2)) c3
from (
select
s.snap_id snapshot,
s.begin_interval_time snaptime,
os1.value - lag(os1.value) over (order by s.snap_id) busydelta,
os2.value - lag(os2.value) over (order by s.snap_id) idledelta
from
See code depot for full script
dba_hist_snapshot s,
dba_hist_osstat os1,
dba_hist_osstat os2
where
s.snap_id = os1.snap_id
and
s.snap_id = os2.snap_id
and
s.instance_number = os1.instance_number
and
s.instance_number = os2.instance_number
and
s.dbid = os1.dbid and s.dbid = os2.dbid
and
s.instance_number = (select instance_number from v$instance)
and
s.dbid = (select dbid from v$database)
and
os1.stat_name = 'BUSY_TIME'
and
os2.stat_name = 'IDLE_TIME'
)),
dbid
as
See code depot for full script
(select dbid my_id from v$database)
select
'SELECT output FROM TABLE'
||' (dbms_workload_repository.awr_report_text ('
||my_id||',1,'||c1||','||to_number(c1+1)||'));'
from
sum_awr,
dbid
where
c3 = (select max(c3) from sum_awr)
;
select 'spool off' from dual;
spool off
|
|
|
Oracle Training from Don Burleson
The best on site
"Oracle
training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!

|
|
|

|
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
feedback. Just
e-mail:
and include the URL for the page.
Copyright © 1996 - 2020
All rights reserved by
Burleson
Oracle ®
is the registered trademark of Oracle Corporation.
|
|