shell脚本实现打印某一个小时的awr报告

用shell脚本实现打印某一个小时的快照,如下:

#*************************************************************************
#  FileName     :               get_awrrpt.sh
#*************************************************************************
#  Author       :               wangwei
#  CreateDate   :               2014-08-25
#  Description  :               this script create a snapshot of the specified 
#                               time 
#             
#*************************************************************************

#!/bin/bash
export ORACLE_HOME=/oracle/oracle/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:/sbin:/bin:/usr/sbin:/usr/bin
export ORACLE_SID=orcl_sid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export ORACLE_BASE=/oracle/oracle
#export ORA_NLS10=$ORACLE_HOME/nls/data
#export NLS_LANG="Simplified Chinese"_China.AL32UTF8
export NLS_LANG=American_America.AL32UTF8
export LANG=C
cd /home/oracle/awrrpt
v_time="$1"

sqlplus -s /nolog <<EOF
connect / as sysdba

set feedback off
set heading off
set termout off
set linesize 10000
set pagesize 50000
set trimspool on
set verify off

column dbid new_value dbid;
column inst_num new_value inst_num;
column bid new_value bid;
column eid new_value eid;
column file_name new_value file_name;

select *  from (select a.dbid,
               a.instance_number inst_num,
               a.startup_time,
               a.snap_id bid,
               a.snap_id + 1 eid,
                'awrrpt_'||a.instance_number ||'_' || to_number(to_char(a.end_interval_time, 'HH24')) || '_' ||
               to_number(to_char(a.end_interval_time, 'HH24') + 1) ||'.html' file_name
          from dba_hist_snapshot a
         where  to_char(a.end_interval_time,'YYYYMMDDHH24')=$v_time
         order by bid
          )
 where inst_num = 1
/
spool &file_name
select output from table(dbms_workload_repository.awr_report_html(&dbid,&inst_num,&bid,&eid,8));
spool off

exit;
EOF

执行脚本./get_awrrpt.sh 2015010609 打印9点到10点的快照


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值