Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1121000
  • 博文数量: 150
  • 博客积分: 2739
  • 博客等级: 少校
  • 技术积分: 2392
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-07 12:28
文章分类

全部博文(150)

文章存档

2015年(2)

2014年(16)

2013年(10)

2012年(58)

2011年(64)

分类: Oracle

2013-02-25 10:44:34

Crontable的设置:

30 23 * * * /bin/bash /usr/local/bin/orahtml.sh 每天晚上23点30分执行:


AWR分析脚本:



#Data: 2013/02/25
#Name:Gavin
#Mail:wkgbc456@163.com
mail=151xxxxxxxx@139.com
export ORACLE_BASE=/disk02/oracle
export ORACLE_SID=capitalv
export ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1
PATH=/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:$PATH;
export PATH=$PATH:$ORACLE_HOME/bin
export PATH
DIRECTORY=/disk02/oracle/html
HTML=ora104_awrrpt_`date +%Y%m%d`.html

############DIRECTORY####
if [ ! -d $DIRECTORY ];then
   echo "The $DIRECTORY is  not exsit";
   exit
fi
cd $DIRECTORY
if [ -f $HTML ];then
  rm -rf $HTML;
fi
#######anyalse oracle web#####
sqlplus /nolog</dev/null
connect / as sysdba
set heading off
spool tempfile.tmp
select min(SNAP_ID) from dba_hist_snapshot;
spool off
!
MINSNAPID=`cat tempfile.tmp|grep -v "SQL>" |grep -v ^$`
 
sqlplus /nolog</dev/null
connect / as sysdba
set heading off
spool tempfile.tmp
select max(SNAP_ID) from dba_hist_snapshot;
spool off
!
MAXSNAPID=`cat tempfile.tmp|grep -v "SQL>" |grep -v ^$`
 
echo "$HTML" >tempfile.tmp
REPORT_NAME=`cat tempfile.tmp`
rm -rf tempfile.tmp
 
echo "define num_days = 1">awrrpt_tmp.sql
echo "define report_type = 'html'">>awrrpt_tmp.sql
echo "define begin_snap = $MINSNAPID">>awrrpt_tmp.sql
echo "define end_snap  = $MAXSNAPID">>awrrpt_tmp.sql
echo "define report_name = '$REPORT_NAME'">>awrrpt_tmp.sql
echo "@@?/rdbms/admin/awrrpt" >>awrrpt_tmp.sql
 
sqlplus /nolog</dev/null
connect / as sysdba
@awrrpt_tmp.sql
!


###########scp web html####################
scp $HTML gavin@192.168.21.50:/var/www/html/oracle/
if [ $? = 0 ] ;then
   echo "Oracle'analyse scp successfully" |mail -s "Oracle analyse" $mail
else
  echo "scp not successfully"|mail -s "Oracle analyse" $mail
fi



                                   
阅读(1506) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

随风飘云2013-02-27 13:01:01

文明上网,理性发言...