Friday, 24 July 2015

Real-Time Automatic Database Diagnostics Monitor (ADDM) in Oracle Database 12c Release 1 (12.1)

The Automatic Database Diagnostics Monitor (ADDM) has been available since Oracle 10g as part of the Diagnostics and Tuning option in Enterprise Edition. ADDM analyzes the contents of the Automatic Workload Repository (AWR) to identify potential performance bottlenecks and attempts to perform root cause analysis of them. Since the AWR snapshots are taken on an hourly basis by default, this has meant ADDM was limited to retrospective analysis on an hourly basis.

Enterprise Manager Cloud Control has included functionality to perform real-time ADDM reports for some time




In addition to the existing ADDM functionality, Oracle Database 12c introduced Real-Time ADDM, which identifies potential performance problems as they happen, analyzes them and stores reports, allowing up-to-the-minute diagnosis of performance problems.

    Overview
    Reports
    DBMS_ADDM.REAL_TIME_ADDM_REPORT Function
    Faking a Problem


Overview

The manageability monitor (MMON) process kicks in every 3 seconds and checks the performance statistics that are currently in memory. If it notices any potential performance issues, it triggers a real-time ADDM analysis run, creates a report and stores it in the Automatic Workload Repository (AWR). The stored reports can be seen in the DBA_HIST_REPORTS view.

The documentation lists the potential triggers for a real-time analysis here.

Reports

Real-time ADDM reports are generated using the "rtaddmrpt.sql" and "rtaddmrpti.sql" scripts in the "$ORACLE_HOME/rdbms/admin" directory.

The "rtaddmrpt.sql" script assumes the report is for the current database and instance, and uses a reporting period of the -60 mins to current time (SYSDATE). This sounds a little like a conventional ADDM report, but the information is sourced from the DBA_HIST_REPORTS view, not the conventional ADDM analysis. An example of running the "rtaddmrpt.sql" script is shown below. Only the report_id and report_name required user input.


SQL> @rtaddmrpt

Current Database
~~~~~~~~~~~~~~~~
 845557242


Instances in this Report reposistory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 845557242        1

Default to current database
Using database id: 845557242

Enter begin time for report:

--    Valid input formats:
--      To specify absolute begin time:
--        [MM/DD[/YY]] HH24:MI[:SS]
--        Examples: 02/23/03 14:30:15
--                  02/23 14:30:15
--                  14:30:15
--                  14:30
--      To specify relative begin time: (start with '-' sign)
--         -[HH24:]MI
--         Examples: -1:15 (SYSDATE - 1 Hr 15 Mins)
--                   -25   (SYSDATE - 25 Mins)

Default to -60 mins
Report begin time specified:

Enter duration in minutes starting from begin time:
Defaults to SYSDATE - begin_time
Press Enter to analyze till current time
Report duration specified:
Using 20/07/2015 09:39:41 as report begin time
Using 20/07/2015 10:39:41 as report end time


Report ids in this workload repository.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 845557242      1922 20/07/2015 10:34:29  High Load                 20.16

Select a report id from the list. If the report id list is empty,
please select a different begin time and end time.
Enter value for report_id: 1922
Report id specified : 1922
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is rtaddmrpt_0720_1039.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: /tmp/rtaddmrpt_0720_1039.html
Using the report name /tmp/rtaddmrpt_0720_1039.html

... Removed HTML Output ...

Report written to /tmp/rtaddmrpt_0720_1039.html
SQL>

You can see the example output here.




The "rtaddmrpti.sql" script allows you to manually select the database and reporting period. The items in bold required user input.

SQL> @rtaddmrpti


Instances in this Report reposistory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     Db Id Inst Num
---------- --------
 845557242        1

Default to current database
Enter value for dbid:

Using database id: 845557242

Enter begin time for report:

--    Valid input formats:
--      To specify absolute begin time:
--        [MM/DD[/YY]] HH24:MI[:SS]
--        Examples: 02/23/03 14:30:15
--                  02/23 14:30:15
--                  14:30:15
--                  14:30
--      To specify relative begin time: (start with '-' sign)
--         -[HH24:]MI
--         Examples: -1:15 (SYSDATE - 1 Hr 15 Mins)
--                   -25   (SYSDATE - 25 Mins)

Default to -60 mins
Enter value for begin_time: -5
Report begin time specified: -5

Enter duration in minutes starting from begin time:
Defaults to SYSDATE - begin_time
Press Enter to analyze till current time
Enter value for duration:
Report duration specified:

Using 20/07/2015 10:29:46 as report begin time
Using 20/07/2015 10:34:47 as report end time


Report ids in this workload repository.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


      DBID REPORT_ID TIME                 trigger_cause             impact
---------- --------- -------------------- ------------------------- ----------
 845557242      1922 20/07/2015 10:34:29  High Load                 20.16

Select a report id from the list. If the report id list is empty,
please select a different begin time and end time.
Enter value for report_id: 1922
Report id specified : 1922
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is rtaddmrpt_0720_1034.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: /tmp/rtaddmrpt_0720_1034.html

Using the report name /tmp/rtaddmrpt_0720_1034.html

... Removed HTML Output ...

Report written to /tmp/rtaddmrpt_0720_1034.html
SQL>

You can see the example output here.















DBMS_ADDM.REAL_TIME_ADDM_REPORT Function

The DBMS_ADDM package contains a function called REAL_TIME_ADDM_REPORT, which looks promising at first glance.

    "This function produces a real-time ADDM report for ADDM-related activity for the last five minutes..."

Unfortunately, it doesn't return a formatted real-time ADDM report, just some data in XML format. You can see the output using the following query.

SET LONG 1000000 LONGCHUNKSIZE 1000000
SET LINESIZE 1000 PAGESIZE 0
SET TRIM ON TRIMSPOOL ON
SET ECHO OFF FEEDBACK OFF

SELECT DBMS_ADDM.real_time_addm_report FROM dual;

Faking a Problem

The reporting scripts described above require records in the DBA_HIST_REPORTS view for the analysis period, or they result in the following error.

declare
*
ERROR at line 1:
ORA-20000: No valid reports found in the specified time range. Please specify a
different begin and end time
ORA-06512: at line 11

If you are looking at a small test system, you may not have any performance problems to monitor, so you will need to fake some. I did this using Swingbench by running the Order Entry workload and locking the SOE.ORDERS table for a few seconds.

CONN sys@pdb1 AS SYSDBA
LOCK TABLE soe.orders IN EXCLUSIVE MODE;

-- Wait a while.

ROLLBACK;



Thanks.
NJ

Active Session History (ASH) Analytics in Oracle Enterprise Manager Cloud Control 12c
The Active Session History (ASH) was introduced in Oracle 10g to provide real-time diagnostics information. ASH Analytics is a feature of Enterprise Manager Cloud Control 12c, which visualises ASH information, making it even simpler to diagnose performance problems.

ASH Analytics is listed as requirement for the 1Z0-060 "Upgrade to Oracle Database 12c" OCP upgrade exam, hence this short overview for those who don't use Cloud Control.

ASH requires the Diagnostics and Tuning option in Enterprise Edition.

Once you've navigated to a database target, the "ASH Analytics" menu will be available under the "Performance" section.

ASH Analytics : Menu




-     On the top-left of the page you will see buttons to quickly alter the monitoring period displayed in the overview graph.

-   The greyed out, selected, area of the activity graph is expanded into a more detailed activity graph below.

-   All the screens under the ASH Analytics section can be saved or emailed by pressing the relevant button.


-The edges of the selection on the overview graph can be repositioned by dragging them with your mouse.  -The expanded activity graph will refresh to match your selection.
- The dropdown allows you to alter the contents of the expanded activity graph.
-The dropdown allows you to customise the contents of this detail section.
-The dropdown allows you to customise the contents of this detail section.



The dropdowns contain the following metrics.

Top Dimensions : Wait Class, Wait Event, Instance, Service, Module, Action, User Session, SQL ID
   
SQL : SQL ID, Top Level SQL ID, SQL Force Matching Signature, SQL Plan Hash Value, SQL Plan Operation, SQL Plan Operation Line, SQL Opcode, Top Level SQL Opcode

   PL/SQL : PL/SQL, Top Level PL/SQL
 
  Resource Consumption : Wait Class, Wait Event, Object, Blocking Session
 
  Session Identifiers : Instance, Service, User Session, Parallel Process, User ID, Program, Session Type
 
  Session Attributes : Consumer Group, Module, Action, Client, Transaction ID, Execution Context ID

     Hovering over the expanded activity graph will highlight the section you are above. Clicking it will apply a filter and redraw the graph based on that filter.

    The filter can be removed by click the "X" on the filter.



Clicking the "Load Map" button will redraw the activity as a load map.



Thanks.