天天看點

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

select instance_name from gv\\$instance;

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;

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;

clear columns sql;

ttitle off;

repfooter off;

undefine report_name

undefine report_type

undefine fn_name

undefine lnsz

undefine NO_OPTIONS

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

炊煙起了;夕陽下了;細雨來了

多調試,互動式程式設計體驗

記錄,獨立思考,對比

感謝轉載作者

修車

國産化

read and connect

匍匐前進,

講故事