• auto ash v1


    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'
    
  • 相关阅读:
    result set sql server
    [转载]:C#、.Net面试题目及答案
    [转载]:合并两个已排序好的int数组,并排序返回c#实现
    [转载]实际举例C#引用类型和值类型的区别
    mysql 性能优化方案
    oracle 并行原理深入解析及案例精粹
    创建Oracle外部表 External Table
    Oracle 分区表
    MySQL索引类型一览
    MySQL配置文件mysql.ini参数详解、MySQL性能优化
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/6138004.html
Copyright © 2020-2023  润新知