Creating several AWR Reports

Execute:
 ./mk_awr.sh 1 --> Number of days
Will generate files for AWRRPT:
 -rw-r--r-- 1 oracle oinstall 178628 Feb 25 16:17 AWR_clonetst_370_371.txt
 -rw-r--r-- 1 oracle oinstall 172747 Feb 25 16:17 AWR_clonetst_371_372.txt
 -rw-r--r-- 1 oracle oinstall 171340 Feb 25 16:17 AWR_clonetst_372_373.txt
 -rw-r--r-- 1 oracle oinstall 169183 Feb 25 16:17 AWR_clonetst_373_374.txt
 -rw-r--r-- 1 oracle oinstall 168289 Feb 25 16:17 AWR_clonetst_374_375.txt
Script Name: mk_awr.sh
 -------------------------------------------------------------
 snapINI=
 snapEND=
 nomeReport=
 reportMODE=text
>snaps.txt
# Number of Days to create
 Days=$1
sqlplus -s " / as sysdba" <<EOF
 set lin 100
 set pages 0
 set head off
 set term off
 set echo off
 set feed off
 col snap_id format 99999
 spool snaps.txt
SELECT snap_id  FROM DBA_HIST_SNAPSHOT WHERE
 TRUNC(BEGIN_INTERVAL_TIME) = TRUNC(SYSDATE)-$Days AND
 INSTANCE_NUMBER in (select instance_number from v\$instance)
 ORDER BY SNAP_ID;
spool off
 exit
 EOF
cat snaps.txt | awk '{print $1}' > snaps1.txt
 mv snaps1.txt snaps.txt
for x in `cat snaps.txt`
 do
snapINI=$x
 snapEND=`expr $x + 1`
 echo $snapINI
 echo $snapEND
 nomeReport='AWR_'$ORACLE_SID'_'$snapINI'_'$snapEND'.txt'
echo 'Creating...'$nomeReport
sqlplus " / as sysdba" @?/rdbms/admin/awrrpt.sql <<EOF
 $reportMODE
 $Days
 $snapINI
 $snapEND
 $nomeReport
 exit
 EOF
 done
-------------------------------------------------------------
Advertisements