Skip to content

Commit 29417c9

Browse files
Merge pull request #1153 from oracle-devrel/uschwinn-patch-21
Add files via upload
2 parents 8fdb0ed + ae6d58b commit 29417c9

24 files changed

+352
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- This procedure adds a filter to capture a subset of the workload.
2+
3+
/* possible filter types: INSTANCE_NUMBER, USER, MODULE, ACTION, PROGRAM, SERVICE, PDB_NAME
4+
5+
examples:
6+
7+
exec dbms_workload_capture.add_filter('ORACLE MANAGEMENT SERVICE (DEFAULT)', 'Program', 'OMS');
8+
exec dbms_workload_capture.add_filter('ORACLE MANAGEMENT AGENT (DEFAULT)', 'Program', 'emagent%');
9+
exec dbms_workload_capture.add_filter('U_DBSNMP', 'User', 'DBSNMP');
10+
*/
11+
12+
-- example
13+
execute dbms_workload_capture.add_filter(fname=>'&FILTERNAME', fattribute=>'&filtertype', fvalue=>'&filtervalue');
14+
15+
-- Monitor filters
16+
set linesize window
17+
select * from dba_workload_filters;
18+
19+
/* if you need to delete the filters
20+
execute DBMS_WORKLOAD_CAPTURE.DELETE_FILTER(fname=>'&Filtername');
21+
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- DBA_WORKLOAD_CAPTURES displays all the workload captures that have been performed in the current database.
2+
3+
set linesize window
4+
select id, name, status, errors, awr_exported, duration_secs, filters_used, dbtime_total, dbtime, dbtime_total,
5+
user_calls_total, user_calls, user_calls_unreplayable, transactions, transactions_total, capture_size/1024/1024
6+
from dba_workload_captures where name like '&name%';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- This function generates a report on the workload capture.
2+
3+
4+
-- Find report_id
5+
select id, name, status, start_time, end_time, awr_exported, connects, user_calls, dir_path
6+
from dba_workload_captures where id = (select max(id) from dba_workload_captures);
7+
8+
-- Generate capture report
9+
spool capturereport.txt
10+
11+
set pagesize 0 long 30000000 longchunksize 1000
12+
select dbms_workload_capture.report(&report_id, 'TEXT') from dual;
13+
14+
spool off
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- This procedure initiates workload capture on all instances.
2+
/*
3+
If you used filters, please review the usage of EXCLUDE and INCLUDE in the start_capture procedure.
4+
Definition:
5+
If EXCLUDE, no user request to the database is captured, except for the part of the workload defined by the filters.
6+
In this case, all the filters specified using the ADD_FILTER procedures are treated as INCLUSION filters, determining
7+
the workload that is captured.
8+
Default is INCLUDE.
9+
10+
-- example with user defined filter criteria
11+
-- execute dbms_workload_capture.start_capture (name=>'&capturename', dir=>'&dir', default_action=>'EXCLUDE');
12+
13+
other options:
14+
15+
-- with STS (not available for RAC)
16+
-- execute dbms_workload_capture.start_capture (name=>'&capturename', dir=>'&dir', capture_sts=>TRUE);
17+
18+
-- with duration
19+
-- execute dbms_workload_capture.start_capture (name=>'&capturename', dir=>'&dir', duration=>&secs);
20+
21+
The optional plsql_mode parameter determines how PL/SQL is handled by DB Replay during capture and replays.
22+
These two values can be set for the plsql_mode parameter:
23+
top_level: Only top-level PL/SQL calls are captured and replayed, which is how DB Replay handled PL/SQL prior
24+
to Oracle Database 12c Release 2 (12.2.0.1). This is the default value.
25+
26+
Extended: Both top-level PL/SQL calls and SQL called from PL/SQL are captured. When the workload is replayed,
27+
the replay can be done at either top-level or extended level.
28+
*/
29+
30+
31+
-- Example EXCLUDE and PL/SQL mode extended
32+
-- execute dbms_workload_capture.start_capture (name=>'&capturename', dir=>'&dir', plsql_mode => 'extended', default_action=>'EXCLUDE');
33+
34+
35+
-- Example INCLUDE (default) and the PL/SQL mode extended
36+
execute dbms_workload_capture.start_capture (name=>'&capturename', dir=>'&dir', plsql_mode => 'extended');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- This procedure signals all connected sessions to stop the workload capture and stops future requests to the database from being captured.
2+
3+
execute dbms_workload_capture.finish_capture();
4+
5+
/*
6+
By default, FINISH_CAPTURE waits for 30 seconds to receive a successful acknowledgement from all sessions in the database cluster before timing out.
7+
All sessions that either were in the middle of executing a user request or received a new user request, while FINISH_CAPTURE
8+
was waiting for acknowledgements, flush their buffers and send back their acknowledgement to FINISH_CAPTURE.
9+
If a database session remains idle (waiting for the next user request) throughout the duration of FINISH_CAPTURE, the session might have unflushed capture buffers and does not send it's acknowledgement to FINISH_CAPTURE. To avoid this, do not have sessions that remain idle (waiting for the next user request) while invoking FINISH_CAPTURE. Either close the database session(s) before running FINISH_CAPTURE or send new database requests to those sessions during FINISH_CAPTURE.
10+
*/
11+
~
12+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- This procedure generates a report comparing a replay to its capture or to another replay of the same capture.
2+
3+
-- find replay_id
4+
select id, awr_begin_snap, awr_end_snap
5+
from dba_workload_replays where name like '&replayname%';
6+
7+
8+
-- replay_id2 of the workload replay whose report is requested
9+
-- If this is NULL, then the comparison is done with the capture
10+
11+
variable result clob
12+
13+
begin
14+
dbms_workload_replay.compare_period_report(replay_id1=>&replayid,replay_id2=>null,format=>'HTML',result=>:result);
15+
end;
16+
/
17+
18+
set heading off
19+
set long 1000000
20+
set pagesize 0
21+
spool comparereport.html rep
22+
print result
23+
spool off
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
set lines 180 pages 100 trimspool on
2+
col num format 999G999G999
3+
col EXPECTED_ERROR_MESSAGE format a32 trunc
4+
col OBSERVED_ERROR_MESSAGE format a32 trunc
5+
col E heading Error_div format a7
6+
col Q heading Query format a5
7+
col D heading DML format a3
8+
col T heading Thread_Error format a13
9+
10+
col spool_file new_value spool_file
11+
12+
select 'divergences' || '_by_sql_id.log' spool_file
13+
from dual;
14+
15+
16+
break on sql_id skip 2 dup
17+
compute sum of Anzahl on sql_id
18+
19+
spool &spool_file
20+
select sql_id, count(*) num,
21+
EXPECTED_ERROR#,
22+
OBSERVED_ERROR#,
23+
lpad(IS_ERROR_DIVERGENCE,4,' ') E,
24+
lpad(IS_QUERY_DATA_DIVERGENCE,3,' ') Q,
25+
lpad(IS_DML_DATA_DIVERGENCE,1,' ') D,
26+
lpad(IS_THREAD_FAILURE,6,' ') T,
27+
EXPECTED_ERROR_MESSAGE,
28+
OBSERVED_ERROR_MESSAGE
29+
from dba_workload_replay_divergence
30+
group by sql_id, EXPECTED_ERROR#, OBSERVED_ERROR#, IS_ERROR_DIVERGENCE,
31+
IS_QUERY_DATA_DIVERGENCE, IS_DML_DATA_DIVERGENCE, IS_THREAD_FAILURE,
32+
EXPECTED_ERROR_MESSAGE, OBSERVED_ERROR_MESSAGE
33+
order by 3, 2 desc,1,4,5,6,7
34+
/
35+
36+
spool off
37+
select sql_id, count(*) Anzahl,
38+
EXPECTED_ERROR#,
39+
OBSERVED_ERROR#,
40+
lpad(IS_ERROR_DIVERGENCE,4,' ') E,
41+
lpad(IS_QUERY_DATA_DIVERGENCE,3,' ') Q,
42+
lpad(IS_DML_DATA_DIVERGENCE,1,' ') D,
43+
lpad(IS_THREAD_FAILURE,6,' ') T,
44+
EXPECTED_ERROR_MESSAGE,
45+
OBSERVED_ERROR_MESSAGE
46+
from dba_workload_replay_divergence
47+
where EXPECTED_ERROR_MESSAGE is not null or OBSERVED_ERROR_MESSAGE is not null
48+
group by sql_id, EXPECTED_ERROR#, OBSERVED_ERROR#, IS_ERROR_DIVERGENCE,
49+
IS_QUERY_DATA_DIVERGENCE, IS_DML_DATA_DIVERGENCE, IS_THREAD_FAILURE,
50+
EXPECTED_ERROR_MESSAGE, OBSERVED_ERROR_MESSAGE
51+
order by 3, 2 desc,1,4,5,6,7
52+
/
53+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- DBA_WORKLOAD_REPLAY_DIVERGENCE displays information about data/error divergence for a user call that has been replayed.
2+
3+
set lines 160 pages 100 trimspool on
4+
col num format 999G999G999 Heading "# of Errors"
5+
col EXPECTED_ERROR# heading "Expected|Error#"
6+
col OBSERVED_ERROR# heading "Observed|Error#"
7+
col EXPECTED_ERROR_MESSAGE format a22 word wrap
8+
col OBSERVED_ERROR_MESSAGE format a40 word wrap
9+
col E heading "Error|Div" format a5
10+
col Q heading "Query|Div" format a5
11+
col D heading "DML|Div" format a3
12+
col T heading "Thread|Error" format a6
13+
14+
break on report
15+
compute sum of Anzahl on report
16+
17+
18+
select count(*) num,
19+
EXPECTED_ERROR#,
20+
OBSERVED_ERROR#,
21+
lpad(IS_ERROR_DIVERGENCE,4,' ') E,
22+
lpad(IS_QUERY_DATA_DIVERGENCE,3,' ') Q,
23+
lpad(IS_DML_DATA_DIVERGENCE,1,' ') D,
24+
lpad(IS_THREAD_FAILURE,6,' ') T,
25+
EXPECTED_ERROR_MESSAGE,
26+
OBSERVED_ERROR_MESSAGE
27+
from dba_workload_replay_divergence
28+
group by EXPECTED_ERROR#, OBSERVED_ERROR#, IS_ERROR_DIVERGENCE,
29+
IS_QUERY_DATA_DIVERGENCE, IS_DML_DATA_DIVERGENCE, IS_THREAD_FAILURE,
30+
EXPECTED_ERROR_MESSAGE, OBSERVED_ERROR_MESSAGE
31+
order by 1 desc,2,3,4,5,6
32+
/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- This procedure exports the AWR snapshots associated with a given capture ID.
2+
3+
-- find the capture_id
4+
select id, name
5+
from dba_workload_captures where name like '%&capturename%';
6+
7+
-- export AWR
8+
execute dbms_workload_capture.export_awr(capture_id =>&captureid);
9+
10+
-- please check the status with capturemon.sql
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- This procedure imports the AWR snapshots from a given replay.
2+
3+
-- find capture id
4+
set serveroutput on
5+
6+
declare
7+
capid number := 0;
8+
BEGIN
9+
capid := DBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO(dir =>'&RATDIR');
10+
dbms_output.put_line('capid is ' || capid);
11+
END;
12+
/
13+
14+
select dbms_workload_capture.import_awr(capture_id => &capid, staging_schema => '&User') from dual;
15+
16+
17+

0 commit comments

Comments
 (0)