Guys,
Good morning!

Today I would like to show you a very popular feature of Oracle Database, called Automatic Workload Repository (AWR), which allows a complete view of the database, such as queries that consume the most I/O, CPU, information about the instance, server, fragmentation, use of indexes, wait events, events that use the most resources and a wide range of information about the behavior of the instance. It is a complete database report and greatly helps the Oracle DBA to investigate and discover possible problems.

Generally, Oracle installations that have a license to use Oracle Enterprise Manager (OEM) generate this report automatically, where the DBA defines an interval and the report is generated according to this interval. In the companies where I worked, this report is generated hourly. If there is a need to generate it for a period of one week, for example, with hourly information to try to identify when some strange behavior of the instance started to occur, I would have to generate each one manually, repeating this 168 times... lol

But let's not do that, right? To solve this problem, I will make this script available to you:
Oracle Database – Generate AWR.

With it, you can specify the start and end day and time and the script generates all files within that period and exports them to a directory of your choice. In order for you to be able to execute this script, you will need to execute 2 simple commands in the database, to create the directory in the database and grant us access to the created directory:

CREATE OR REPLACE DIRECTORY awr_reports_dir AS '/tmp/awr';
GRANT READ, WRITE ON DIRECTORY AWR_REPORTS_DIR TO dirceu.resende;

Ready. Just run the script, enter the desired period and download the generated HTML files. Happy analysis, DBAs!