How to generate awr in a rac instance for every one hour ( snapshot)
# Jeyaseelan
if [ $# -ne 2 ] ; then
echo usage : ./awr.sh instance_number date
echo ./awr.sh 1 12-JUN-2011
exit
fi
# Directory where this script resides
set -xv
STATSDIR=.
STATSREP=.
INSTANCE_NUMBER=$1
CURR_DATE=$2
AWRREPORT=snap.sql
# -------------------------------------------------->
# ---------- Start of program
rm $AWRREPORT
echo "Generating reports in $STATSREP ... Pls wait ..."
sqlplus -s /nolog <<!
conn / as sysdba
set serveroutput on size 1000000
set feed off term off trims on linesize 300
dbms_output.put_line('database connection');
spool $AWRREPORT
declare
min_snap number;
next_snap number;
min_snap_time varchar2(20);
next_snap_time varchar2(20);
fileName varchar2(255);
cursor c1 is select instance_number,snap_id, to_char(startup_time,'ddmm_hh24mi') snap_time from dba_hist_snapshot where instance_number=$INSTANCE_NUMBER and to_char(BEGIN_INTERVAL_TIME,'dd-MON-yyyy') = '$CURR_DATE' order by snap_id;
c1_rec c1%rowtype;
begin
for c1_rec in c1 loop
select min(snap_id) into next_snap from dba_hist_snapshot where snap_id > c1_rec.snap_id and instance_number=$INSTANCE_NUMBER;
select to_char(end_interval_time,'ddmonyyy_hh24mi') into next_snap_time from dba_hist_snapshot where instance_number=$INSTANCE_NUMBER and snap_id = next_snap;
dbms_output.put_line('define begin_snap='||c1_rec.snap_id);
dbms_output.put_line('define end_snap='||next_snap);
fileName := '$STATSREP'||'/'||'$ORACLE_SID'||'_awrrpt'||'_'||c1_rec.instance_number||'_'||c1_rec.snap_id||'_'||next_snap||'.lst';
dbms_output.put_line('define report_name='||fileName);
dbms_output.put_line('define report_type='||'text');
dbms_output.put_line('define num_days='||'3');
dbms_output.put_line('@$ORACLE_HOME/rdbms/admin/awrrpt');
end loop;
exception
when no_data_found then
-- Only last snap remaining
null;
when others then
dbms_output.put_line(sqlerrm);
end;
/
spool off
!
echo test
sqlplus -s /nolog <<!
conn / as sysdba
@$AWRREPORT
!
Dear Friends, The content in this blog are purely based on my own opinion ,it is not reflecting any of my current or previous employers materials or official documents. All my posts here are not warranted to be free of errors. Please use at your own risk and after thorough testing in your environment. If you feel that i am violating any of the company's policies or documents, kindly mail me at jeyaseelan.hi@gmail.com,I am happy to take out those content from this blog.
Subscribe to:
Post Comments (Atom)
-
We may not be able to disable the logtransport when the database is in maximum availabilty mode. We may get the below error DGMGRL...
-
Error Messages: We may get the following error messages while doing ASM operations ORA-15137: The ASM cluster is in rolling patch state....
-
MIRA - Multi Instance Redo Apply - 12cR2 onwards/18C With Oracle 12c Release 2, We can enable Multi Instance Redo apply ( MIR...
No comments:
Post a Comment