星期一, 4月 09, 2012

[Oracle 10g] 監控ASM空間 , ASM mail scripts by checking its free percentage

Q:為何要設定此監控程式
A:根據監控free space , 才有辦法預先在資料庫空間快不夠時,去新增,否則等到滿了,肯定又是一場災難!

以下為Solaris bash shell 的範例
#content of mail_asm_alert.sh 
#export ORACLE_HOME to ASM_HOME , if installed
export DB=$(ps -ef |grep +ASM |grep -i pmon |awk {'print $9'} |sed -e 's/asm_pmon_//g')
export ORACLE_SID=${DB}
export ORAENV_ASK=NO
export SPOOL_FILE=/backup/rman/scripts/pct_free_asm.log;
ALERT=30

sqlplus / as sysdba <<EOF
spool $SPOOL_FILE
set heading off
--select round(total_mb/1024,2) Total_GB, round(free_mb/1024,2) Free_GB,round(free_mb/total_mb*100,2) pct_Free from v$asm_diskgroup where total_mb > 1;
select ''||NAME||' Pct '||round(free_mb/total_mb*100) pct_Free
from v\$asm_diskgroup where total_mb > 1;
spool off
EOF

#Check DATA diskgroup and REDO diskgroup...
asm_data_pct=`cat $SPOOL_FILE |grep "DATA"|grep -v SQL\> |awk '{print $3}'`
asm_redo_pct=`cat $SPOOL_FILE |grep "REDO"|grep -v SQL\> |awk '{print $3}'`

#Compare operator should be less then by default , ie asm_pct 20% , ALERT 30%
#Test the result by setting -lt to -gt below...
if [ -s $SPOOL_FILE ] && ( [ $asm_data_pct -gt $ALERT ] || [ $asm_redo_pct -gt $ALERT ] ) ; then
  echo "ASM DISKGROUP SHORT ON SPACE - PAGE SENT"
  cat $SPOOL_FILE | mailx -r dbadmin@domain.net -s "`hostname` ASM_DISK spact pct $asm_pct remain! " receiver@domain.net
fi

Mail 的結果如下:




沒有留言:

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...