startdate=$1
enddate=$2
#reporttype=$3
#reportformat='text'
oraclehome=`echo $ORACLE_HOME`

dbid=`sqlplus -s "/ as sysdba" <<EOF
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select distinct dbid from gv\\$database;
quit;
EOF
`

instname=`sqlplus -s "/ as sysdba" <<EOF
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select instance_name from gv\\$instance;
quit;
EOF
`
echo "generate the ash report sql...."
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF

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';
column ext new_value ext noprint
column fn_name new_value fn_name noprint;
column lnsz new_value lnsz noprint;
select 'html' ext from dual where lower('&report_type') = 'html';
select 'ash_report_html' fn_name from dual where lower('&report_type') = 'html';
select '1500' lnsz from dual where lower('&report_type') = 'html';
set linesize &lnsz;
column report_name new_value report_name noprint;
select instance_name||'_ashrpt_1_'|| to_char(to_date('$startdate', 'yyyy-mm-dd hh24:mi:ss'), 'yyyymmddhh24miss') ||'.'||'&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',to_date('$startdate', 'yyyy-mm-dd hh24:mi:ss'),to_date('$enddate', 'yyyy-mm-dd hh24:mi:ss'),0));
spool off;
set termout on;
clear columns sql;
ttitle off;
repfooter off;
undefine report_name
undefine report_type
undefine fn_name
undefine lnsz
undefine NO_OPTIONS
quit;
EOF

chmod +x autoash.sh
sh autoash.sh '2016-06-29 10:15:00' '2016-06-29 10:30:00'

auto ash v1的更多相关文章

  1. auto和decltype(c++11)

    1.auto 1)auto是一个类型说明符(类型说明符就是像int.double这样的),用来定义一个变量,它可以让编译器去分析表达式的类型,并使用该表达式的值去初始化变量 //auto定义的变量必须 ...

  2. C++ auto类型说明符

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50864612 编程时常常需要把表达式的 ...

  3. leetcode 165

    才一周没刷leetcode,手就生了,这个题目不难,但是完全AC还是挺费劲的. 题目描述: Compare two version numbers version1 and version2.If v ...

  4. 【cpp】Vector

    这vector 很有用 // compile with: /EHsc #include <vector> #include <iostream> int main() { us ...

  5. C++STL -- vector 使用

    vector是一种顺序容器. vector常用API: 现在一个个分析: 1. assign 这是一种赋值方法,但是会覆盖原来容器内的值. void assign( size_type num, co ...

  6. 一种高效的 vector 四则运算处理方法

    实现 vector 的四则运算 这里假设 vector 的运算定义为对操作数 vector 中相同位置的元素进行运算,最后得到一个新的 vector.具体来说就是,假如 vector<int&g ...

  7. 《C++Primer》复习——with C++11 [4]

    考虑到STL的掌握主要靠的是练习,所以对于STL这部分,我把书中的练习都做一遍,加深印象.这些练习是第9.10.11.17章的,分别是顺序容器.泛型算法和关联容器等. ——10月22日 /*----- ...

  8. C++ 11 vlearning

    1.新增算术类型     longlong,最小不比long小,一般为64位. 2.列表初始化      int units_sold = {0};或者 int units_sold{0};非11标准 ...

  9. c++ primer (5)1

    第一章 1.包含来自标准库的头文件用<>,不属于标准库用"". 2.默认情况,读cin会刷新cout:程序非正常终止时也会刷新cout. 3.默认情况,cerr不缓冲, ...

随机推荐

  1. HUST 1339 Reversal(字符串)

    题目链接 题解:将每个单词倒置,可以用char数组,然后用空格分隔,这里用的是string和stringstream. #include <cstdio> #include <ios ...

  2. java中的字符编码方式

    1. 问题由来 面试的时候被问到了各种编码方式的区别,结果一脸懵逼,这个地方集中学习一下. 2. 几种字符编码的方式 1. ASCII码 我们知道,在计算机内部,所有的信息最终都表示为一个二进制的字符 ...

  3. 第三次冲刺spring会议(第四次会议)

    [例会时间]2014/5/23 21:15 [例会地点]9#446 [例会形式]轮流发言 [例会主持]马翔 [例会记录]兰梦 小组成员:兰梦 ,马翔,李金吉,赵天,胡佳奇

  4. NOIP2014-普及组复赛-第二题-比例简化

    题目描述 Description 在社交媒体上,经常会看到针对某一个观点同意与否的民意调查以及结果.例如,对某一观点表示支持的有1498 人,反对的有 902人,那么赞同与反对的比例可以简单的记为14 ...

  5. 【笔记】虚拟机用Xshell登陆报错“ssh服务器拒绝了密码”解决方法

    自己本地安装了VMware Workstation之后,创建虚拟机,一开始是可以用Xshell登陆的,几天后,重启了电脑以及虚拟机,发现无法登陆了,还没有输入密码就有如下报错信息 这时候开始排查原因, ...

  6. ArrayList和LinkedList和Vector源码分析

    ArrayList源码: private static final int DEFAULT_CAPACITY = 10;//默认长度 /** * Shared empty array instance ...

  7. Activity间切换的动画应用

    Activity切换过程中,系统会使用一些默认的动画,显得切换过程不至于太呆板. 在frameworks/base/core/res/res/values下的stlyes.xml文件中有具体的定义各个 ...

  8. 2015 Multi-University Training Contest 4

    1001 Olympiad 签到题1. # include <iostream> # include <cstdio> using namespace std; ]={}; b ...

  9. Pivot Index--Google

    Return the pivot index of the given array of numbers. The pivot index is the index where the sum of ...

  10. YaHoo Web优化的14条法则

    Web应用性能优化黄金法则:先优化前端程序(front-end)的性能,因为这是80%或以上的最终用户响应时间的花费所在. 法则1. 减少HTTP请求次数 80%的最终用户响应时间花在前端程序上,而其 ...