Windows Batch Script to Generate AWR Report

February 24, 2017 | Author: Pravin Srinivas | Category: N/A
Share Embed Donate


Short Description

Download Windows Batch Script to Generate AWR Report...

Description

Windows Batch Script To Generate AWR Report Step 1: Choose “Type” Step 2: Copy Text 1 and Text 2 from selected “Type” Step 3: Paste Text 1 and Text 2 in File_Name.bat ( i) Make Sure that copied text should be paste in straight line. Step 4: Double click File_Name.bat to execute .bat file  Type 1: Script to generate Hourly report Text 1: echo SELECT max((SNAP_ID)-1)FROM DBA_HIST_SNAPSHOT where begin_interval_time ^> trunc(sysdate); >> first_query.sql Text 2: echo SELECT max(SNAP_ID) FROM DBA_HIST_SNAPSHOT where begin_interval_time ^> trunc(sysdate); >> first_query.sql  Type 2: Script to generate Daily report Text 1: echo SELECT min(SNAP_ID) FROM DBA_HIST_SNAPSHOT where begin_interval_time ^> trunc(sysdate); >> first_query.sql Text 2: echo SELECT max(SNAP_ID) FROM DBA_HIST_SNAPSHOT where begin_interval_time ^> trunc(sysdate); >> first_query.sql  Type 3: Script to generate Weekly report Text 1: echo SELECT min(SNAP_ID) FROM DBA_HIST_SNAPSHOT where begin_interval_time ^> trunc(sysdate -7); >> first_query.sql Text 2: echo SELECT max(SNAP_ID) FROM DBA_HIST_SNAPSHOT where begin_interval_time ^> trunc(sysdate -7); >> first_query.sql

File_Name.bat @echo off echo SET LINES 400 > first_query.sql echo SET PAGES 400 >> first_query.sql echo set head off >> first_query.sql echo COL BEGIN_INTERVAL_TIME FOR A40 >> first_query.sql echo COL END_INTERVAL_TIME FOR A40 >> first_query.sql echo Spool min_snap_id.log >> first_query.sql

Paste Here (Text 1) echo Spool off; >> first_query.sql echo Spool max_snap_id.log >> first_query.sql

Paste Here (Text 2) echo Spool off; >> first_query.sql echo spool db_id.log >> first_query.sql echo SELECT DBID FROM V$DATABASE; >> first_query.sql echo Spool off; >> first_query.sql echo exit >> first_query.sql sqlplus / as sysdba @ first_query.sql for /f "tokens=* delims=" %%A in (db_id.log) do set databaseid=%%A for /f "tokens=* delims=" %%A in (min_snap_id.log) do set minsnap=%%A for /f "tokens=* delims=" %%A in (max_snap_id.log) do set maxsnap=%%A echo SET HEADING OFF; > gen_awrrpt.sql echoSET FEEDBACK OFF; >> gen_awrrpt.sql echo SET LINESIZE 1500; >> gen_awrrpt.sql echo PROMPT GETTING HTML FORMAT REPORT: >> gen_awrrpt.sql

echo SPOOL AWR_REPORT_HTML.HTML; >> gen_awrrpt.sql echo SELECT OUTPUT FROM TABLE (DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML >> gen_awrrpt.sql echo (%databaseid%, >> gen_awrrpt.sql echo 1,%minsnap% >> gen_awrrpt.sql echo ,%maxsnap% >> gen_awrrpt.sql echo ,8 >> gen_awrrpt.sql echo ) >> gen_awrrpt.sql echo ); >> gen_awrrpt.sql echo SPOOL OFF; >> gen_awrrpt.sql echo exit >> gen_awrrpt.sql sqlplus / as sysdba @ gen_awrrpt.sql end del db_id.log del min_snap_id.log del max_snap_id.log del gen_awrrpt.sql del first_query.sql

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF