--自动生成AWR报告
-------------------2013/09/23
脚本代码:
#!/bin/bash
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`
MIN_SNAP_ID=`expr $MAX_SNAP_ID - 1`
AWR_LOG=/tmp/AWR_shahand_`date '+%Y%m%d_%H%M'`.html
echo -e "$AWR_FORMAT
$NUM_DAYS
$MIN_SNAP_ID$MAX_SNAP_ID
$AWR_LOG
"|(sqlplus -S / as sysdba @?/rdbms/admin/awrrpt.sql) > /dev/null