這篇文章給大家分享的是有關(guān)單個(gè)腳本如何監(jiān)控主機(jī)上所有實(shí)例的表空間利用率的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
創(chuàng)新互聯(lián)建站主營(yíng)曲水網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開(kāi)發(fā),曲水h5成都小程序開(kāi)發(fā)搭建,曲水網(wǎng)站營(yíng)銷(xiāo)推廣歡迎曲水等地區(qū)企業(yè)咨詢(xún)
借助一個(gè)文件,存放ps –ef | grep pmon的輸出
[test]:/orasw/dba>more /orasw/dba/scripts/ db_running.log
oracle 8922 1 0 Dec 17 ? 10:48 ora_pmon_spw2005p
oracle 13535 1 0 Dec 17 ? 10:00 ora_pmon_mstrmd1p
oracle 28599 1 0 Dec 19 ? 10:39 ora_pmon_tsr2008p
oracle 7561 1 0 Dec 17 ? 11:57 ora_pmon_asa2p
oracle 6756 1 0 Dec 17 ? 11:53 ora_pmon_tsr2009p
oracle 12041 1 0 Dec 17 ? 11:01 ora_pmon_spw06p
oracle 6737 1 0 Dec 17 ? 10:57 ora_pmon_spw2003p
oracle 16046 1 0 Dec 17 ? 12:32 ora_pmon_crs2007t
oracle 5002 1 0 Dec 19 ? 10:04 ora_pmon_smart3p
shell腳本
1 遍歷該文件,將sid取出
2 遍歷sid 列表,分別執(zhí)行檢查表空間sql腳本,并將結(jié)果發(fā)送給相關(guān)人員
#!/bin/ksh
db_name=`cat /orasw/dba/scripts/ db_running.log|awk 'BEGIN { FS = "_" } ; { print $3 }'|sed '/^$/d'`
echo $db_name
for k in $db_name
do
h=`ps -ef | grep pmon | grep -c $k`
echo $k
ORACLE_SID=$k; export ORACLE_SID
ORAENV_ASK=NO
. oraenv
#. oraenv
export ORACLE_HOME
# Set threshhold limit for tablespace to send alert
#
export threshold=70
export script_dir=/orasw/dba/scripts/
rm -rf $script_dir/${k}_ts.rpt
rm -rf $script_dir/${k}_chk_ts.out
cut_of_pt=$threshold
tmp_file=$script_dir/${k}_chk_ts.out
ts_stat_rpt=$script_dir/${k}_ts.rpt
sqlplus -s '/ as sysdba' @$script_dir/chk_ts.sql >> $ts_stat_rpt <<-EOF
exit
EOF
echo "TABLESPACE_NAME PCT_USED(%)" > $tmp_file
echo "-----------------------------" >> $tmp_file
cat $ts_stat_rpt | awk '{
if (int($2) > int("'$cut_of_pt'"))
print $0
}' >> $tmp_file
echo "----------------------------------" >> $ts_stat_rpt
if test -s $tmp_file
then
subject="Below TableSpaces crossed threshold limits of $cut_of_pt in $k. Please take immediate action."
echo $subject
mailx -s "$subject"***@***.com < $tmp_file
fi
done
相應(yīng)sql腳本
bash-3.2$ more chk_ts.sql
set lines 120
set pages 100
set echo off
set feedback off
set head off
col PCT_USED format a10
col tablespace_name format a20
(select t.tablespace_name tablespace_name,TO_CHAR((1 - DECODE(tsf.bytes, NULL, tsa.bytes, tsf.bytes) / tsa.bytes) * 100, '990') PCT_USED
from sys.dba_tablespaces t, sys.sm$ts_avail tsa, sys.sm$ts_free tsf
where t.tablespace_name = tsa.tablespace_name and t.tablespace_name = tsf.tablespace_name (+)
)
union
(SELECT D.TABLESPACE_NAME TABLESPACE_NAME, TO_CHAR(DECODE(A.SUM_ALLOCATE, NULL, 0, NVL(T.SUM_USED, 0) / A.SUM_ALLOCATE * 100), '990') PCT_USED
FROM DBA_TABLESPACES D,
(SELECT TABLESPACE_NAME, SUM(BYTES) SUM_ALLOCATE FROM DBA_TEMP_FILES GROUP BY TABLESPACE_NAME) A,
(SELECT TABLESPACE_NAME, SUM(BYTES_CACHED) SUM_USED FROM V$TEMP_EXTENT_POOL GROUP BY TABLESPACE_NAME) T
WHERE D.TABLESPACE_NAME = A.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = T.TABLESPACE_NAME(+)
AND D.EXTENT_MANAGEMENT = 'LOCAL' AND D.CONTENTS = 'TEMPORARY'
)
/
感謝各位的閱讀!關(guān)于“單個(gè)腳本如何監(jiān)控主機(jī)上所有實(shí)例的表空間利用率”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
文章名稱(chēng):單個(gè)腳本如何監(jiān)控主機(jī)上所有實(shí)例的表空間利用率
轉(zhuǎn)載注明:http://www.rwnh.cn/article46/gcgeeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、靜態(tài)網(wǎng)站、、網(wǎng)站建設(shè)、網(wǎng)站排名、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)