Recently learning shell programming, a little bit of gadgets to automate the collection of AWR reports, to facilitate problems in the system when troubleshooting.
The contents of the script are as follows, the system collects the AWR report from 20 o'clock to the end of the daily start time 6 o'clock and is stored in the/u01/shell_t/awr/directory.
#! /bin/sh
Export ORACLE_SID=PROD1
Export Oracle_base=/u01/app/oracle
Export Oracle_home=/u01/app/oracle/product/11.2.0/dbhome_1
m= (' sqlplus-s '/as SYSDBA << EOF
Set pagesize 0 feedback off verify off heading off echo off
Select Max (snap_id) from Dba_hist_snapshot where Begin_interval_time>to_date (To_char (sysdate, ' yyyy-mm-dd ') | | ' 06
', ' yyyy-mm-dd HH24 ') and End_interval_time<=to_date (To_char (sysdate, ' yyyy-mm-dd ') | | ' , ' Yyyy-mm-dd HH24 ');
EOF ')
n= (' sqlplus-s '/as SYSDBA << EOF
Set pagesize 0 feedback off verify off heading off echo off
Select min (snap_id) from Dba_hist_snapshot where Begin_interval_time>to_date (To_char (sysdate, ' yyyy-mm-dd ') | | ' 06
', ' yyyy-mm-dd HH24 ') and End_interval_time<=to_date (To_char (sysdate, ' yyyy-mm-dd ') | | ' , ' Yyyy-mm-dd HH24 ');
EOF ')
Name= (' sqlplus-s '/as SYSDBA << EOF
Set pagesize 0 feedback off verify off heading off echo off
Select instance_name from v\\\ $instance;
EOF ')
date= (' sqlplus-s '/as SYSDBA << EOF
Set pagesize 0 feedback off verify off heading off echo off
Select To_char (sysdate, ' yyyymmddhh24 ') from dual;
EOF ')
Sqlplus-s "/As SYSDBA" <<eof
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/awrrpt.sql;
Html
1
$n
$m
/u01/shell_t/awr/awrrpt_1_${name}_${date}.html
Eof
A shell script that automatically generates an AWR report