指令碼:定時生成awr報告

linfeng_oracle發表於2014-06-18

指令碼:定時生成awr報告


#!/bin/sh
ORACLE_SID=$1
export ORACLE_SID
source ~/.bash_profile
mkdir -p /oracle/utils/statspack/$1
WORKPATH=/oracle/utils/statspack/$1
AWR_FORMAT=html
NUM_DAYS=1

MAX_SNAP_ID=`sqlplus -S / as sysdba << EOF      
set heading off trimspool on feedback off
SELECT trim(max(SNAP_ID)) FROM DBA_HIST_SNAPSHOT;
EOF`
export MAX_SNAP_ID


MIN_SNAP_ID=`expr $MAX_SNAP_ID - 1`
export MIN_SNAP_ID
echo $MIN_SNAP_ID


AWR_LOG=$WORKPATH/report/AWR_$1_${MIN_SNAP_ID}.html
export AWR_LOG
echo $AWR_LOG

echo -e "$AWR_FORMAT\n$NUM_DAYS\n$MIN_SNAP_ID$MAX_SNAP_ID\n$AWR_LOG\n"|(sqlplus -S / as sysdba @?/rdbms/admin/awrrpt.sql) > /dev/null

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24996904/viewspace-1188456/,如需轉載,請註明出處,否則將追究法律責任。

相關文章