A shell script that automatically generates an AWR report

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.