1.

#! /bin/ksh

#set -x

SID=$1

ORACLE_SID=stat10g
ORACLE_HOME=/oracle10g/product/10.2
PATH=$PATH:/usr/bin:/usr/sbin:$ORACLE_HOME/bin:.:/usr/local/bin
export ORACLE_SID ORACLE_HOME  PATH

DATE=`date +%Y%m%d`
BASEDIR=/home/oracle/monitor/segment_size
LOGDIR=/database/log/segment_size

#Window DBs
DATABASE="boeprod newsdb"

#LOGG=/${BASEDIR}/win.log
#>LOGG

for i in ${DATABASE}
do
LOG=/${LOGDIR}/log/${i}_`date '+%Y%m%d'`.log

sqlplus oper/oper123<< EOF > ${LOG}
set echo off
--heading on feedback on head on serveroutput on
prompt "tbs utilization:"
set line 142;
set pagesize 1000;
col tablespace_name for a30;
set num 10;
col instance_name for a15
col used_ for 999,990.90;
col free_ for a15;
col free_percentage for a15;

select a.tablespace_name,all_sum "all_sum(M)",
 to_char(nvl(free_sum,0),'9,999,990.00')||'M' free_,
 to_char(100*nvl(free_sum,0)/all_sum,'900.00')||'%' free_percentage,instance_name
  from
  (select tablespace_name,sum(bytes)/1024/1024 all_sum
   from dba_data_files@${i}
   group by tablespace_name) a,
  (select tablespace_name,sum(bytes)/1024/1024 free_sum
   from dba_free_space@${i}
   group by tablespace_name) c, v\$instance@${i}
  where
  a.tablespace_name = c.tablespace_name(+)
  order by 4
/

prompt "tbs percentage utilization:"
--tbs percentage utilization
select tablespace_name,  to_char(sysdate,'YYYY-MM') "Date", org_mb total, free_mb free, pct_free pct_free,
--CASE WHEN (  (((0.8*org_mb)-free_mb)/(1-0.8))    < 1) THEN 0
--     ELSE  (((0.8*org_mb)-free_mb)/(1-0.8))
--     END as "Free80%-Add",
CASE WHEN (  (((0.2*org_mb)-free_mb)/(1-0.2))    < 1) THEN 0
     ELSE (((0.2*org_mb)-free_mb)/(1-0.2))
     END as "Free20%-Add",
CASE WHEN (  (((0.17*org_mb)-free_mb)/(1-0.17))  < 1) THEN 0
     ELSE (((0.17*org_mb)-free_mb)/(1-0.17))
     END as "Free17%-Add",
CASE WHEN (  (((0.16*org_mb)-free_mb)/(1-0.16))  < 1) THEN 0
     ELSE (((0.16*org_mb)-free_mb)/(1-0.16))
     END as "Free16%-Add",
CASE WHEN (  (((0.15*org_mb)-free_mb)/(1-0.15))  < 1) THEN 0
     ELSE (((0.15*org_mb)-free_mb)/(1-0.15))
     END as "Free15%-Add"
from
( select a.tablespace_name
      ,((sum(a.bytes)/1024/1024)/max(b.Org_Mb))*100 Pct_free
      ,max(b.Org_Mb) Org_Mb
      ,max(b.Org_Mb) - sum(a.bytes)/1024/1024 Used_Mb
      ,sum(a.bytes)/1024/1024 Free_Mb
      ,max(a.bytes)/1024/1024 Max_Mb
from   dba_free_space@${i} a,
      (select tablespace_name ,sum(bytes)/1024/1024 Org_Mb from   dba_data_files@${i} group by tablespace_name) b
where  a.tablespace_name = b.tablespace_name
group by a.tablespace_name
order by 1 desc
)
/

col file_name for a55
col tablespace_name for a30
select tablespace_name,file_name,autoextensible,sum(maxbytes)/1024/1024 totalbytes,sum(bytes)/1024/1024 bytes from dba_data_Files@${i} group by tablespace_name,file_name,autoextensible order by tablespace_name,file_name
/

prompt"top20seg:"
--top20seg.sql
--def run_dt = sysdate - 6 months
def incr_percent = 0
def lower_bound = 65536
col owner for a12
col seg_type for a12
col segment_name for a35
col "%Growth+" for '999'

select to_char(s1.run_date,'YYYYMMDD HH24:MI:SS') origin_date,s1.owner, s1.segment_type seg_type,s1.segment_name, s1.extents "last_exts", s2.extents "cur_exts", s1.bytes "last_bytes", s2.bytes "cur_bytes", round(((s2.bytes - s1.bytes)/s1.bytes)*100,2) "%Growth+"
from ${i}_segmon_statistics s1, dba_segments@${i} s2
where s1.segment_name = s2.segment_name
and   s1.owner = s2.owner
and   s1.segment_type = s1.segment_type
and   nvl(s1.partition_name,'*') = nvl(s2.partition_name,'*')
and  ( ((s2.extents - s1.extents)/s1.extents) * 100 >= &incr_percent or ((s2.bytes - s1.bytes)/s1.bytes)*100 >= &incr_percent)
and s2.bytes > &lower_bound
and s1.run_date = (select min(run_date) from ${i}_segmon_statistics)
order by 9,2,3,4
/

column capture_date format A11
column segment_name format A35
column segment_type format A15
column owner format A20
column MB format 99,999.99

select to_char(sysdate,'YYYY-MON-DD') capture_date,owner,segment_name,segment_type,tablespace_name,sum(bytes)/1024/1024 MB
from dba_segments@${i}
where owner not in ('OUTLN','SCOTT','SYSTEM')
group by owner,segment_name,segment_type,tablespace_name   having (sum(bytes)/1024/1024 >5)
order by MB  desc
/
exit;
EOF

cat ${LOG}
#/bin/mailx -s "Temporary monitor ${i} tablespace" ts-dba@aa.com.cn <  ${LOG};
#cat ${LOG}>>${LOGG}
done

2.

PWD=/database/log/segment_size
LOG=${PWD}/tbs_windows_rep.log

echo "TABLESPACE_NAME                all_sum(M) FREE_           FREE_PERCENTAGE INSTANCE_NAME" >${LOG}
echo "------------------------------ ---------- --------------- --------------- ----------------">>${LOG}
grep '%' ${PWD}/tbs_win_all.log|grep -v '%G' |grep -v '%-' |sed 's/.*://g' |sort -uk 4 >> ${LOG}
#cat ${LOG}

#(echo "Windows DB tablespace's size monitor data:";/usr/bin/uuencode ${LOG} ${LOG}) | /bin/mailx -s "Windows DB tablespace's size monitor `date '+%Y-%m-%d' `"  ts-dba@aa.com.cn
echo "Windows DB tablespace's size monitor data:" | /bin/mailx -s "Windows DB tablespace's size monitor `date '+%Y-%m-%d' `"  ts-dba@aa.com.cn <${LOG}

3.fixed:

因为使用到了db_link.所以新增加数据库,也需要新增加db_link.

for pdb

conn oper/oper123
create   database   link   pcwspprod   connect   to   oper   identified   by   oper123   using   'pcwspprod';

for cdb
conn c##oper/oper123
create   database   link   cwspprod   connect   to   c##oper   identified   by   oper123   using   'cwspprod';

tablespace monitor shell for windows的更多相关文章

  1. linux shell 和linux 命令的区别?windows shell 和 windows 命令呢?

    shell翻译成壳的意思,它是包裹在linux内核外层的,一个可通过一系列的linux命令对操作系统发出相关指令的人机界面. shell可以通过其条件语句和循环语句等,把一系列linux命令结合在一起 ...

  2. 如何在Python脚本中调用外部命令(就像在linux shell或Windows命令提示符下输入一样)

    如何在Python脚本中调用外部命令(就像在linux shell或Windows命令提示符下输入一样) python标准库中的subprocess可以解决这个问题. from subprocess ...

  3. Jenkins 六: 构建中执行shell或者 windows的批处理程序

    Shell/ bat Jenkins 可以在构建中执行shell命令或者windows的batch 命令. 1. 选择一个项目,点击“配置”. 2. 找到“构建” –> “增加构建步骤”.选择 ...

  4. 利用SSH secure Shell实现windows与linux之间传输文件

    在windows下安装SSH secure Shell.默认安装后有两个快捷方式. linux下需要安装openssh-server utuntu默认安装了opens是-client,所以不需要安装, ...

  5. python 调用shell或windows命令

    目前使用到的有两种方式:os.system()和os.popen() import os os.system('cd e:cjx') #调用后返回执行结果状态 如果想获得返回结果,则使用以下方式: i ...

  6. (C#)Windows Shell 外壳编程系列7 - ContextMenu 注册文件右键菜单

    原文 (C#)Windows Shell 外壳编程系列7 - ContextMenu 注册文件右键菜单 (本系列文章由柠檬的(lc_mtt)原创,转载请注明出处,谢谢-) 接上一节:(C#)Windo ...

  7. Writing a Windows Shell Extension(marco cantu的博客)

    Writing a Windows Shell Extension This is a technical article covering the content of my last week s ...

  8. Windows Power Shell简介

    Windows PowerShell 是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用 .NET Framework的强大功能. 它引入了许多非常有用的新概念,从而进一步扩展了您在 W ...

  9. windows快捷命令修炼

    Description Windows Key combination Open/Close the Start Menu Windows key Open the Action center. Wi ...

随机推荐

  1. Codeforces 651B Beautiful Paintings【贪心】

    题意: 给定序列,重新排序,使严格上升的子序列最多.求这些子序列总长度. 分析: 贪心,统计每个元素出现次数,每次从剩余的小的开始抽到大的,直到不再剩余元素. 代码: #include<iost ...

  2. cogs——555. 网络探测

    555. 网络探测 ★☆   输入文件:ping.in   输出文件:ping.out   简单对比时间限制:1 s   内存限制:128 MB [问题描述]    当出现网络故障时,我们经常使用“p ...

  3. Maven具体解释之仓库------本地仓库、远程仓库

    在Maven中,不论什么一个依赖.插件或者项目构建的输出.都能够称之为构件. Maven在某个统一的位置存储全部项目的共享的构件.这个统一的位置.我们就称之为仓库.(仓库就是存放依赖和插件的地方) 不 ...

  4. 11gR2 RAC环境重建ASM SPFILE

    有关11gR2 ASM spfile说明能够看 http://blog.csdn.net/robo23/article/details/41930051 下面粘出spfile重新启动过程: +++1) ...

  5. leetcode第一刷_Best Time to Buy and Sell Stock

    这样的题就不要去考虑N^2的算法了.肯定会超时的.乍一看,非常可能会想到贪心,可是普通的贪心思路是不行的,比方想找到一个最小值用来买入.尽管它跟最大值之间的差一定是最好的,可是最大值出如今它前面就不行 ...

  6. VMWare无法共享文件夹(Win7宿主机\Ubuntu14.04客户机)

    在安装VMWare tools的时候,需要执行 vmware-install.pl.在安装过程中,需要编译vmhgfs module,如果编译失败就很可能导致共享文件夹无法正常挂载. 最近,我在虚拟机 ...

  7. 【bzoj4412】[Usaco2016 Feb]Circular Barn

    先看成一条链 for一遍找位置 在for一遍算答案 #include<algorithm> #include<iostream> #include<cstring> ...

  8. [mac]WireShark检測不到网卡怎么办?

    wireshark是一个很好用的抓包工具,有windows版本号和mac版本号,在mac下安装wireshark,启动后发现提示"There are no interfaces on whi ...

  9. css3 3d特效汇总

    本篇全是实战,没有基础,如果不明白3d特效的原理,可能会看不懂,不过没关系,给你推荐一下 张鑫旭css3 3d转换,或者看我的另一篇博客  css3 2d转换3d转换以及动画的知识点汇总,看完这些3d ...

  10. 怎么查询数据库中第30到40条记录呢? 通过ID,查询当前第30-40条记录 注意,ID不是顺序的

    http://blog.csdn.net/lee576/article/details/5812347 http://bbs.csdn.net/topics/190070614 http://www. ...