自动ASH报告脚本

注:只有在ORACLE 10.2以上的版本才支持ASH报告,在执行此脚本前请确认你的版本是否支持

rem autoash.sql

set echo off;
set feedback off;
set termout on;
set heading off;

variable rpt_options number;

define NO_OPTIONS = 0;
-- define ENABLE_ADDM = 8;

rem according to your needs, the value can be 'text' or 'html'
define report_type='html';
begin
  :rpt_options := &NO_OPTIONS;
end;
/

variable dbid number;
variable inst_num number;

begin
  select dbid into :dbid from v$database;
  select instance_number into :inst_num from v$instance;
end;
/

column ext new_value ext noprint
column fn_name new_value fn_name noprint;
column lnsz new_value lnsz noprint;

--select 'txt' ext from dual where lower('&report_type') = 'text';
select 'html' ext from dual where lower('&report_type') = 'html';
--select 'awr_report_text' fn_name from dual where lower('&report_type') = 'text';
select 'ash_report_html' fn_name from dual where lower('&report_type') = 'html';
--select '80' lnsz from dual where lower('&report_type') = 'text';
select '1500' lnsz from dual where lower('&report_type') = 'html';

set linesize &lnsz;

column report_name new_value report_name noprint;

--select 'awrrpt_1_'||:bid||'_'||:eid||'.'||'&ext' report_name from dual;
--select instance_name||'_awrrpt_1_'||:bid||'_'||:eid||'.'||'&ext' report_name from v$instance;
select instance_name||'_ashrpt_1_'|| sysdate ||'.'||'&ext' report_name
   from v$instance a;
set termout off;
spool &report_name;

select output from table(dbms_workload_repository.&fn_name(:dbid, :inst_num,sysdate-1/72,sysdate,0));
spool off;
set termout on;
clear columns sql;
ttitle off;
title off;
repfooter off;
undefine report_name
undefine report_type
undefine fn_name
undefine lnsz
undefine NO_OPTIONS

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9375/viewspace-627216/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9375/viewspace-627216/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值