天天看點

oracle 表空間檢視腳本

#!/bin/bash

echo -e "\n\n*********~~~~~~~~~~~~~~~~~~~~~~~~~~~~DATE:" `date '+%Y/%m/%d   %T'` "~~~~~~~~~~~~~~~~~~~~~~~*********" >>/home/oracle/tablespace.log

export PATH=/opt/oracle/1102/db01/bin:$PATH

export ORACLE_HOME=/opt/oracle/1102/db01/

sqlplus -S /nolog <<eof

conn xx/xx@orcl

spool /home/oracle/tablespace.log append 

set line 200;

set feedback off;

set pagesize 50000;

col member for a45;

select a.tablespace_name,a.summary,b.free,b.maxf "MAX_FREE_EXTENT",b.free_exts "FREE_EXTENTS",

    100-b.free/a.summary*100 "USED%"

        from

           (select tablespace_name,sum(bytes/1024/1024) "SUMMARY" from dba_data_files

               group by tablespace_name) a,

                   (select tablespace_name,sum(bytes/1024/1024) "FREE",max(bytes/1024/1024)

                      "MAXF" ,count(*) free_exts

                          from dba_free_space group by tablespace_name) b

                              where a.tablespace_name=b.tablespace_name

                                 order by 6 desc;

--col SQL_TEXT for a50

--select t.SQL_TEXT,t.VERSION_COUNT,t.SHARABLE_MEM from v\$sqlarea t where t.VERSION_COUNT>6;

                                 spool off;

eof

df -m >>/home/oracle/tablespace.log

                                 exit;

######################################################

将上述内容儲存到/tmp/tablespace.sh中

然後通過crontab  -l -u oracle指令建立計劃任務如下:

1 * * * * /bin/bash  tmp/tablespace.sh

則每小時将會執行一次腳本,結果将會儲存到home/oracle/tablespace.log中

以上為在redhat6.4中驗證

本文轉自shangshanyang51CTO部落格,原文連結:http://blog.51cto.com/qqran/1877099 ,如需轉載請自行聯系原作者