Generating Workload Replay Reports Using APIs

You can generate a workload replay report using the DBMS_WORKLOAD_REPLAY package. You can also use Oracle Enterprise Manager to generate a workload replay report, as described in "Accessing Workload Replay Reports Using Enterprise Manager".

To generate a report on the latest workload replay for a workload capture using APIs:

  1. Retrieve information about the workload captures and the history of the workload replay attempts from the replay directory object by calling the DBMS_WORKLOAD_REPLAY.GET_REPLAY_INFO function, as described in "Retrieving Information About Workload Replays".

    The GET_REPLAY_INFO function returns the cap_id of a single capture directory (for a consolidated capture directory, the cap_id returned is 0).

  2. Using the cap_id that was returned by the GET_REPLAY_INFO function, run a query to return the appropriate rep_id for the latest replay of the workload.

  3. Call the DBMS_WORKLOAD_REPLAY.REPORT function.

    The REPORT function generates a report using the rep_id that was returned by the SELECT statement.

    The REPORT function uses the following parameters:

    • The replay_id required parameter specifies the directory that contains the workload replay for which the report will be generated. The directory should be a valid directory in the host system containing the workload replay. The value of this parameter should match the rep_id returned by the previous query.

    • The format parameter required parameter specifies the report format. Valid values include DBMS_WORKLOAD_REPLAY.TYPE_TEXT, DBMS_WORKLOAD_REPLAY.TYPE_HTML, and DBMS_WORKLOAD_REPLAY.TYPE_XML.

In this example, the GET_REPLAY_INFO function retrieves all information about the workload captures and the history of all the workload replay attempts from the jul14 replay directory object. The function returns the cap_id of the capture directory, which can be associated with the CAPTURE_ID column in the DBA_WORKLOAD_REPLAYS view to access the information retrieved.The SELECT statement returns the appropriate rep_id for the latest replay of the workload. The REPORT function then generates a HTML report using the rep_id that was returned by the SELECT statement.

DECLARE
  cap_id         NUMBER;
  rep_id         NUMBER;
  rep_rpt        CLOB;
BEGIN
  cap_id := DBMS_WORKLOAD_REPLAY.GET_REPLAY_INFO(replay_dir => 'jul14');
  /* Get the latest replay for that capture */
  SELECT max(id)
  INTO   rep_id
  FROM   dba_workload_replays
  WHERE  capture_id = cap_id;
 
  rep_rpt := DBMS_WORKLOAD_REPLAY.REPORT(replay_id => rep_id,
                           format => DBMS_WORKLOAD_REPLAY.TYPE_HTML);
END;
/

For information about how to interpret the workload replay report, see "Reviewing Workload Replay Reports".

See Also: