zoukankan      html  css  js  c++  java
  • 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'
    
  • 相关阅读:
    Win7 64位 php-5.5.13+Apache 2.4.9+mysql-5.6.19 配置
    C# .NET 使用第三方类库DotNetZip解压/压缩Zip rar文件
    64位window7,php5.5.10 +IIS7 配置
    eclipse下编译openfire3.9.1源码
    asp.net 解决IE11下 From身份验证失效问题
    MySQL 数据类型 详解
    ASP.NET安全
    Microsoft Anti-Cross Site Scripting Library V4.2 下载地址
    Entityframework Core去掉外键
    VS2019发布Docker实践
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/6138004.html
Copyright © 2011-2022 走看看