1. 程式人生 > >表空間和文件系統使用率監控腳本

表空間和文件系統使用率監控腳本

pac tin exit sele 系統 ava ota then set

 1 . ~/.profile 
 2 jvcmd="/usr/java14/jre/bin/java"
 3 agtjar="/tmp/ty/NotifyAgent.jar"
 4 phoneNbr="-p 13300000000"
 5 
 6 /oracle11/oracle/product/11.2.0.4/dbhome_1/bin/sqlplus / as sysdba > test1.log <<EOF
 7 set heading off
 8 select a.tablespace_name, round(100*(1-free/total),1) usage from
 9   (select tablespace_name,sum
(bytes)/(1024*1024) total from dba_data_files group by tablespace_name) a , 10 (select tablespace_name,sum(bytes)/(1024*1024) free from dba_free_space group by tablespace_name) b 11 where a.tablespace_name=b.tablespace_name(+) ; 12 exit 13 EOF 14 15 cat test1.log|grep IBA3 > test2.log 16 tbs=`cat test2.log|awk
{print $1}` 17 ratio=`cat test2.log|awk {print $2}` 18 msg1=`hostname`": " 19 for i in $ratio 20 do 21 if [ $i -ge 95 ];then 22 tbs=`cat test2.log|grep $i|awk {print $1}` 23 msg1=${msg1}${tbs}","${i}"%" 24 $jvcmd -jar $agtjar -a 1 $phoneNbr -c $msg1 25 else 26 continue;
27 fi 28 done 29 30 fs=`df -g|grep /ogg|awk {print $4}|cut -d "%" -f1` 31 msg2=`hostname`": " 32 if [ $fs/1 -ge 90 ];then 33 msg2=${msg2}"/ogg "${fs}"%" 34 $jvcmd -jar $agtjar -a 1 $phoneNbr -c $msg2 35 fi

用於監控表空間和文件系統使用率,在超過閥值時,可以小短信提醒!

表空間和文件系統使用率監控腳本