系統管理
1753506 會員
5321 線上
108794 解決方案
發表新文章

請高手幫一下忙!(SOS)

 
watermelonyu
教授

請高手幫一下忙!(SOS)

下列內容是 database 的alert.log 請問有高手可以寫成script 將 每天檢查 並將有error 的部分send mail 給我

例如:

Mon Feb 13 18:06:06 2006

Errors in file /opt/oracle/admin/corpora/udump/ora_7396.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-02067: transaction or savepoint rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02068: following severe error from WKS_PROD

ORA-03113: end-of-file on communication channel

ORA-06512: at line 30

Mon Feb 13 18:06:49 2006

Thread 1 advanced to log sequence 34390

Current log# 1 seq# 34390 mem# 0: /pdmcorp/datafile/redo/redocorpora01.log

Mon Feb 13 18:06:56 2006

Errors in file /opt/oracle/admin/corpora/udump/ora_7464.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-02067: transaction or savepoint rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02068: following severe error from AIZ

ORA-03113: end-of-file on communication channel

ORA-06512: at line 85

Mon Feb 13 19:00:14 2006

Thread 1 advanced to log sequence 34391

Current log# 2 seq# 34391 mem# 0: /pdmcorp/datafile/redo/redocorpora02.log

Mon Feb 13 19:00:41 2006

Thread 1 advanced to log sequence 34392

Current log# 3 seq# 34392 mem# 0: /pdmcorp/datafile/redo/redocorpora03.log

希望send mail的結果是:

Mon Feb 13 18:06:06 2006

Errors in file /opt/oracle/admin/corpora/udump/ora_7396.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-02067: transaction or savepoint rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02068: following severe error from WKS_PROD

ORA-03113: end-of-file on communication channel

ORA-06512: at line 30

Mon Feb 13 18:06:56 2006

Errors in file /opt/oracle/admin/corpora/udump/ora_7464.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-02067: transaction or savepoint rollback required

ORA-02055: distributed update operation failed; rollback requ
3則回覆 3
watermelonyu
教授

請高手幫一下忙!(SOS)

抱歉有點打錯:

我希望的可以只得到Error message就好 如下:

Mon Feb 13 18:06:06 2006

Errors in file /opt/oracle/admin/corpora/udump/ora_7396.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-02067: transaction or savepoint rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02068: following severe error from WKS_PROD

ORA-03113: end-of-file on communication channel

ORA-06512: at line 30

Mon Feb 13 18:06:56 2006

Errors in file /opt/oracle/admin/corpora/udump/ora_7464.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-02067: transaction or savepoint rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02055: distributed update operation failed; rollback required

ORA-02068: following severe error from AIZ

ORA-03113: end-of-file on communication channel

ORA-06512: at line 85

請高手幫忙 thanks
watermelonyu
教授

請高手幫一下忙!(SOS)

Hi, for your reference



(vpar2)hputainw:/tmp/ora#cat ora_alert.sh

#!/usr/bin/sh

tmpfile=/tmp/alert$$

alertlog=/tmp/ora/alert.log

mailto="To: oracle_dba@hp.com"

TOD=`date +%m/%d/%Y`

subject="Subject: $TOD Alertlog"



echo "From: oracle_dba@hp.com" > $tmpfile

echo $mailto >> $tmpfile

echo $subject >> $tmpfile

echo "Precedence: bulk" >> $tmpfile

echo >> $tmpfile



echo "$TOD Alertlog" >>$tmpfile

echo "==========================" >> $tmpfile

grep -E "^ORA-|^Error|2006$" $alertlog >> $tmpfile



/usr/sbin/sendmail -t < $tmpfile



rm -f $tmpfile



======== end script =========

crontab -l

1 1 * * * /tmp/ora/ora_alert.sh > /dev/null 2>&1
watermelonyu
教授

請高手幫一下忙!(SOS)

可以安裝 OEM, 然後設定 event, 只要 Oracle DB 遇到 ora- 的錯誤訊息, 它就會自動發 mail 給你