zoukankan      html  css  js  c++  java
  • 监控表空间利用,数据文件

    自己编写的监控表空间利用率的小脚本,这个脚本没有监控temp表空间

    这个脚本按照表空间使用率降序排列

    col tablespace_name format a15
    col total_space format a10
    col free_space format a10
    col used_space format a10
    col used_rate format 99.99
    select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m' free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
    (1-(b.free_space_Mb/a.total_space_Mb))*100 used_rate,a.total_blocks,b.free_blocks from                   
    (select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files group by tablespace_name) a,
    (select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space group by tablespace_name) b
    where a.tablespace_name=b.tablespace_name order by used_rate desc;

    这个脚本格式化了百分比

    col tablespace_name format a15
    col total_space format a10
    col free_space format a10
    col used_space format a10
    col used_rate format a10
    select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m' free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
    round((1-(b.free_space_Mb/a.total_space_Mb)),4)*100||'%' used_rate,a.total_blocks,b.free_blocks from                   
    (select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files group by tablespace_name) a,
    (select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space group by tablespace_name) b
    where a.tablespace_name=b.tablespace_name;

    上面两个脚本没有考虑数据文件是否能自动增长,下面的脚本考虑数据文件能自动增长的情况

    col tablespace_name heading Tablespace_Name
    col allocated_space heading Allocated_Space
    col free_space heading Free_Space(Mb)
    col max_spacee heading Max_space(Mb)
    select a.tablespace_name,a.total_space_mb allocated_space,round(b.free_space_mb,2) free_space,round(a.max_space,2) max_space,
    round((a.total_space_mb-b.free_space_mb)/a.total_space_mb*100,2) pct_usage,round(a.total_space_mb/a.max_space*100,2) pct_allocated
    from (select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,decode(sum(maxbytes/1024/1024),0,
    sum(bytes)/1024/1024,sum(maxbytes)/1024/1024) max_space
     from dba_data_files group by tablespace_name)a,(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb
     from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_name order by pct_allocated desc;

    监控数据文件脚本

    col max_size heading Max_Size(Gb)
    col file_size heading File_Size(Mb)
    col next heading Next(Bytes)
    col autoextensible heading Auto
    col file_name heading File_Name
    col tablespace_name heading Tablespace_Name
    col free_size heading Free_Size(Mb)
    col used_rate heading Pct.used
    select tablespace_name,file_name,bytes/1024/1024 file_size,round(a.free_size,2) free_size,autoextensible,increment_by next,round(maxbytes/1024/1024/1024)
    max_size,round(((bytes/1024/1024)-a.free_size)/(bytes/1024/1024)*100,2) used_rate from dba_data_files b,(select file_id,sum(bytes)/1024/1024 free_size from dba_free_space group by file_id) a
    where b.file_id=a.file_id order by used_rate desc;

  • 相关阅读:
    Android实现文件上传功能(接收端用strust2)
    创建一个多页面,基于UINavigationController的控制的跳转的iOS应用程序
    NSURL中带有汉字参数的乱码处理
    Google Directions API通过请求获取导航数据简介
    iOS下用UIWebView打开文档
    关于Objectivec和Java下DES加密保持一致的方式
    struts2中通过Action以InputStream的下载文件以及在iOS以及Android端接收的实现方式
    NSURL中的参数带有特殊字符的处理
    UIColor设置自定义的颜色不成功问题
    Android中TabHost中实现标签的滚动以及一些TabHost开发的奇怪问题
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330645.html
Copyright © 2011-2022 走看看