脚本:定时生成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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24996904/viewspace-1188456/