auto_ash
#!/usr/bin/ksh
##############paramter######################
startdate=$1' 00:00:01'
enddate=$2' 23:59:59'
reporttype=$3
reportformat='text'
###################env######################
oraclehome=`echo $ORACLE_HOME`
#############################################
dbname=`sqlplus -s "/ as sysdba" <<EOF
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select distinct name from gv\\$database;
quit;
EOF
`
dbid=`sqlplus -s "/ as sysdba" <<EOF
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select distinct dbid from gv\\$database;
quit;
EOF
`
instid=`sqlplus -s "/ as sysdba" <<EOF
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select instance_number from gv\\$instance;
quit;
EOF
`
instname=`sqlplus -s "/ as sysdba" <<EOF
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select instance_name from gv\\$instance;
quit;
EOF
`
for i in $instid
do
instanceid=`echo $i|tr -d ' '`
echo "from database-->"$dbname" database id--->"$dbid" instance id--->"$instanceid
echo "report type--->"$reporttype"|"$reporttype" snapshot from--->"$startdate" to--->"$enddate
echo $instanceid
if [ $reporttype = 'AWR' ];
then
export NLS_LANG=american_america.AL32UTF8
echo "generate the awr report sql...."
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF >awrreport.sql
set head off
set echo off
set feedback off
set linesize 120 ;
set pagesize 0;
set heading off;
select * from (
select snap_id as snaped,
lag(snap_id, 1) OVER(ORDER BY snap_id) as snapst,
to_char(end_interval_time, 'yyyymmddhh24miss') as snaped1,
lag(to_char(end_interval_time, 'yyyymmddhh24miss'), 1) OVER(ORDER BY to_char(end_interval_time, 'yyyymmddhh24miss')) as snaped2
from dba_hist_snapshot a
where a.begin_interval_time >=to_date('$startdate', 'yyyy-mm-dd hh24:mi:ss')
and a.begin_interval_time <=to_date('$enddate', 'yyyy-mm-dd hh24:mi:ss')
--and rtrim(ltrim(to_char(a.begin_interval_time,'day','NLS_DATE_LANGUAGE=AMERICAN'))) not in ('saturday','sunday')
--and to_char(a.begin_interval_time,'HH24')>=0
--and to_char(a.end_interval_time,'HH24') <=23
and a.DBID='$dbid'
and a.INSTANCE_NUMBER='$instanceid'
) where snapst is not null AND substr(snaped1,1,8)=substr(snaped2,1,8)
order by snapst;
quit;
EOF
export NLS_LANG=american_america.AL32UTF8
cat awrreport.sql | while read line
do
endd=`echo $line | awk ' { print $1 } '`
startd=`echo $line | awk ' { print $2 } '`
endt=`echo $line | awk ' { print $3 } '`
startt=`echo $line | awk ' { print $4 } '`
instid=`echo $instanceid`
awrrp="awrrpt_"$startt"_"$endt"_"$instid".txt"
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF
@?/rdbms/admin/awrrpti.sql;
$reportformat
$dbid
$instanceid
1
$startd
$endd
$awrrp
quit;
EOF
done
echo "generate the node"$instid "report finish,please check..."
else
echo "error!!!please check the input parameters..."
fi
done
tar cvf awr.tar *.txt
2. how to
chmod +x auto-awr-11g.sh
nohup sh auto-awr-11g.sh '2016-05-26' '2016-06-02' AWR & 3.FAQ:
ash出现ORA-01843: 无效的月份错误解决
select sysdate from dual;
本帖最后由 drower 于 2013-10-16 15:36 编辑
今天在做优化第十四课作业生成ash时出现错误 通过alter session set nls_date_format='DD-MM-YY';修改当前会话。 |
感谢逝鸿 https://blog.csdn.net/qq_21127313/article/details/52471580
ORA-01843 When Generating ASH Report (文档 ID 1147253.1)
Please set nls_language to AMERICAN and re-generate the ASH report:
SQL> alter session set nls_language='AMERICAN';
SQL> @?/rdbms/admin/ashrpt.sql
[appuser@pommodb02 ~]$ env|grep LANG
LANG=en_US.UTF-8
-》正确机器
[appuser@sportalfront01 ~]$ env|grep LANG
LANG=zh_CN.UTF-8
auto_ash的更多相关文章
随机推荐
- 草料生成app自动下载的二维码
草料官网http://cli.im/app 填写iOS和安卓的appid就好了
- C#微型网页查看工具
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- PHP导出一个txt文本文件
<?php Header( "Content-type: application/octet-stream "); Header( "Accept-Ranges ...
- javascript 奇淫巧技1
1.首次为变量赋值时务必使用var关键字 变量没有声明而直接赋值得话,默认会作为一个新的全局变量,要尽量避免使用全局变量. 2.使用===取代== ==和!=操作符会在需要的情况下自动转换数据类型.但 ...
- 如何理解CSS中的浮动 :其实他就像乘坐扶梯一样
只要你用过自动扶梯,你就能很快的理解CSS中的浮动(Float). 你肯定遇到过这样的情况: 做好了,你想用CSS浮动来调整元素间的位置关系. 在写完代码之后,你发现浮动元素没出现在你设想 ...
- Linux启动kettle及linux和windows中kettle往hdfs中写数据(3)
在xmanager中的xshell运行进入图形化界面 sh spoon.sh 新建一个job
- MVC3+EF4.1学习系列(十)----MVC+EF处理树形结构
通过前几篇文章 我们处理了 一对一, 一对多,多对多关系 很好的发挥了ORM框架的做用 但是 少说了一种 树形结构的处理, 而这种树形关系 我们也经常遇到,常见的N级类别的处理, 以及经常有数据与类别 ...
- LeetCode OJ 119. Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...
- 网页 CSS样式表
昨天,我主要是对CSS样式表进行了一下复习. CSS样式表主要有三类:内联样式表.内嵌样式表.外部样式表,我们平时一般使用第二种样式表. 选择器主要包括:标签选择器.class选择器.ID选择器.复合 ...
- Android 图片显示
一.Android手机显示图片 若R.G.B每种颜色使用一个字节(8bit)表示,每幅图像可以有1670万种颜色:若R.G.B每种颜色使用两个字节(16bit)表示,每幅图像可以有10的12次方种颜色 ...