Oracle AWR配置脚本例子

#!/bin/bash

awr_file=/opt/bigops/data/awr/$(date +%Y%m%d%H%M%S%s).html

conn="用户名/密码@//IP:1522/service_name"

dbid=`sqlplus -S ${conn} << "EOF"
set pagesize 0;
select trim(dbid) from v$database;
EOF`

inst_num=`sqlplus -S ${conn} << "EOF"
set pagesize 0;
select trim(instance_number) from gv$instance;
EOF`

eid=`sqlplus -S ${conn} << "EOF"
set pagesize 0;
select trim(max(snap_id)) from dba_hist_snapshot;
EOF`

if [ "${eid}" -gt 24 ];then
    bid=$(echo $eid|awk '{print $1-24}')
else
    bid=1
fi

awr_content=$(sqlplus -S ${conn} << EOF
set linesize 5000; 
set feed off;
set echo off;
set veri off;
set feedback off;
set termout on;
set heading off;
select output from table(dbms_workload_repository.awr_report_html(l_dbid=>${dbid}, l_inst_num=>${inst_num}, l_bid=>${bid}, l_eid=>${eid}));
EOF
)

if [ $? == 0 ];then echo "exec_status=成功";else echo "exec_status=失败";fi

echo "${awr_content}">${awr_file}
echo "awr_file=$(echo ${awr_file})"
echo "awr_file_size=$(du -sh ${awr_file}|awk '{print $1}')"

results matching ""

    No results matching ""