A bash script for generating multiple AWR reports.
GOAL

You can automate AWR reports generation in the Oracle Database by using the dbs_gawrr.sh bash script. The provided script simplifies the AWR generation process when there is a need to generate multiple AWR reports quickly for database analysis.

SOLUTION

The script is meant to generate multiple AWR reports between 2 snap IDs. The script requires a begin snap ID, an end snap ID, the interval between snap IDs, and the directory path for storing generated reports.

s|start      - A begin SNAP ID 
e|end        - An end SNAP ID 
i|increment  - [Optional] A number of snapshots in a report. The default is 1.
d|directory  - [Optional] A directory for storing AWR reports. The default is the script directory.
debug        - [Optional] Enables debug output when executing the script 

For instance

## To generate 1 AWR report based on 5 snapshots 

./dbs_gawrr.sh s=1 e=5 i=5 

## To generate 4 AWR reports based on 2 adjacent snapshots each
## Snapshots ranges are 1-2, 2-3, 3-4, 4-5

./dbs_gawrr.sh s=1 e=5 i=1 
NOTE

Convert the script from DOS text file format to UNIX text file format

{
wget https://dbpilot.net/wp-content/uploads/2022/01/dbs_gawrr.v003.zip --no-check-certificate
unzip dbs_gawrr.v003.zip
chmod 500 dbs_gawrr.sh
dos2unix dbs_gawrr.sh
}

Example of the script usage

## To display all available AWR snapshots execute the dbs_gawrr.sh script without any parameter

oracle@dbpilot|22:41|~:<tst19c> ./dbs_gawrr.sh

-------------------------------
-- Available AWR Snapshots:
-------------------------------

           1 04-JAN-2022 17:30
           2 04-JAN-2022 19:00
           3 04-JAN-2022 20:00
           4 04-JAN-2022 21:00
           5 07-JAN-2022 13:08
           6 07-JAN-2022 14:00
           7 07-JAN-2022 15:00
           8 07-JAN-2022 18:29
           9 07-JAN-2022 19:00
          10 08-JAN-2022 13:55
          11 08-JAN-2022 15:00
          12 08-JAN-2022 16:00
          13 08-JAN-2022 17:00
          14 08-JAN-2022 18:00
          15 08-JAN-2022 19:00
          16 09-JAN-2022 21:48

-------------------------------
-- How to use the script
-------------------------------

  ./dbs_gawrr.sh s= e= [i= d= debug]

  [   s=  ] is a snapshot id to start from.
  [   e=  ] is a snapshot id to end on.
  [   i=  ] is an interval for getting the next snapshot id. The default value is 1.
  [   d=  ] is a directory for reports. The default one is a directory where the script is located.
  [ debug ] is the optional argument for printing out debug information while the script is executing.
## Generate AWR reports by specifying parameters for s= and =e arguments 

oracle@dbpilot|22:41|~:<tst19c> ./dbs_gawrr.sh s=11 e=15 i=2

  Number of available snapshots  : 16
  Lower available snapshot ID    : 1
  Highest available snapshot ID  : 16

  Requested start snapshot ID    : 11
  Requested end snapshot ID      : 15
  Requested snapshot interval    : 2
  Directory for reports          : /home/oracle

  11 - 13
  13 - 15

oracle@dbpilot|22:41|~:<tst19c> ls -l *html
-rw-r--r--. 1 oracle dba 647089 Jan  9 22:41 TST19C_08_JAN_2022_1500_1700_11_13.html
-rw-r--r--. 1 oracle dba 702459 Jan  9 22:41 TST19C_08_JAN_2022_1700_1900_13_15.html

Written At
09 JAN 202223:00
Red Hat Release
7.x x64
Database Release
19.13.0.0.0