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的更多相关文章
随机推荐
- 鼠标点击 input,显示瞬间的边框颜色,对之修改与隐藏
示例的是项目中的遇到的,要做成的效果是点击该图片按钮,达到切换图片的效果: HTML代码如下: <input class="dBox3Ulimg" type="im ...
- 修改win7锁定界面背景
Regedit HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Authentication/LogonUI/Backgrou ...
- Java 工具 JUnit单元测试
Java 工具 JUnit单元测试 @author ixenos 1.1. JUnit单元测试框架的基本使用 一.搭建环境: 导入junit.jar包(junit4) 二.写测试类: 0,一般一个 ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- stl实现结构体排序关键语法要点(sort)
sort函数,调用时使用函数头: #include <algorithm> sort(begin,end);用来表示一个范围. int _tmain(int argc, _TCHAR* a ...
- HTML中的<audio>和<video>标签讲解
关于<audio>标签讲解:点击这里 这里来一段简单的html5的音频代码: <audio src="someaudio.wav"> 您的浏览器不支持 au ...
- sed 一些用法
sed /^[[:space:]]*$/d 删除空行 sed "/^$/d" 删除空行 sed "/^#/d" 删除 开 ...
- ElasticSearch(5)-Mapping
一.Mapping概述 映射 为了能够把日期字段处理成日期,把数字字段处理成数字,把字符串字段处理成全文本(Full-text)或精确的字符串值,Elasticsearch需要知道每个字段里面都包含了 ...
- Zeppelin使用phoenix解释器
Interpreters设置
- HDU 2614 Beat(DFS)
题目链接 Problem Description Zty is a man that always full of enthusiasm. He wants to solve every kind o ...