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. 免费数据库(SQLite、Berkeley DB、PostgreSQL、MySQL、Firebird、mSQL、MSDE、DB2 Express-C、Oracle XE)

    SQLite数据库是中小站点CMS的最佳选择 SQLite 是一个类似Access的轻量级数据库系统,但是更小.更快.容量更大,并发更高.为什么说 SQLite 最适合做 CMS (内容管理系统)呢? ...

  2. Infix to posfix 自己写stack,没有()

    #include<iostream> #include<string> using namespace std; template<typename Type> s ...

  3. luci页面“save&apply”的实现分析

    页面上配置的“保存&应用”功能的实现: 最终调用到/etc/config/ucitrack的配置文件. 例如配置无线时,对应ucitrack配置文件中的config network    op ...

  4. PBO

    #include <GL/glew.h> #include <GL/freeglut.h> #include <iostream> GLuint pboID[]; ...

  5. Docker 制作mysql镜像

    # 拉取Ubuntu镜像 docker pull docker.io/ubuntu: # 运行一个容器 docker run --name mysql -p 33:3306 -v /mysql:/va ...

  6. 聊天系统Demo,增加文件传送功能(附源码)-- ESFramework 4.0 快速上手(14)

    本文我们将介绍在ESFramework 4.0 快速上手(08) -- 入门Demo,一个简单的IM系统(附源码)的基础上,增加文件传送的功能.如果不了解如何使用ESFramework提供的文件传送功 ...

  7. inno setup 安装个界面提示信息修改

    对于inno setup打包的安装文件,各界面中的提示信息可以在安装编译脚本 xxx.iss 中的 [Messages] 段设置,如果不知道要设置的信息的变量名,可以到 inno setup的安装目录 ...

  8. redis数据类型:Strings

    String是最简单的数据类型,一个key对应一个value,string类型是二进制安全的,redis的String可以包含任何数据, 比如jpg图片或者系列化的对象. Set方法: 设置key对应 ...

  9. Linux下搭建ntp时间同步服务器

    1.ntpd软件安装(略过) 2.修改ntp.conf配置文件 vi /etc/ntp.conf 第一种配置:允许任何IP的客户机都可以进行时间同步将“restrict default kod nom ...

  10. SCALA STEP BY STEP

    http://www.artima.com/scalazine/articles/steps.html http://hongjiang.info/scala/