静坐常思己过,闲谈莫论人非,能受苦乃为志士,肯吃亏不是痴人,敬君子方显有德,怕小人不算无能,退一步天高地阔,让三分心平气和,欲进步需思退步,若着手先虑放手,如得意不宜重往,凡做事应有余步。持黄金为珍贵,知安乐方值千金,事临头三思为妙,怒上心忍让最高。切勿贪意外之财,知足者人心常乐。若能以此去处事,一生安乐任逍遥。

在solaris下面发送ORACLE Alert信息邮件的脚本

作者:大鹏 发布于:2012-4-16 21:02 Monday 分类:Unix & Linux

#!/bin/ksh 
#----------------------------------------------------------------------- 
# PROGRAM:        CheckAlertLog.ksh 
# USAGE:          CheckAlertLog.ksh 
# FUNCTION:       Checks ORACLE Alert logs and pages in case of 
#                  any new errors. SID is Oracle database identifier. 
# CALLED BY:      cron 
#  
# CASCADE FILES:  $LIBDIR/pagers.txt $LIBDIR/dbinfo.txt $LIBDIR/oraErrCount_${SID} 
# AUTHOR          Rochael Zhang
# Date            Mon Apr  16 18:01:56 PDT 2012 
#----------------------------------------------------------------------- 

SID=app1                      # Oracle database identifier 
ALERTDIR=/opt/oracle8i/admin/oracle/bdump                # Directory where Oracle alert file resides 
FILE=alert_${SID}.log            # Oracle alert file name 
MAILX=/usr/bin/mailx             # UNIX Mail Program 
LIBDIR=${HOME}/zlx_scripts      # Directory where useful information is saved 
LASTCOUNT=`cat $LIBDIR/oraErrCount_${SID}`  # Count of ORA- errors 
                                          # detected during last program run 
DBINFO=`cat $LIBDIR/dbinfo.txt` 

export MAILX 
export LIBDIR 
export ALERTDIR 

sendAlertMessage() 

{ 
MESSAGE="**ALARM**:${SID} from ${DBINFO}:`grep "ORA-" $ALERTDIR/$FILE | tail  -1 | head -1`" 
   for LIST in `egrep "DBA" $LIBDIR/pagers.txt` 
   do 
      EMAIL=`echo $LIST | awk -F: '{ print $2 }'` 
      echo $MESSAGE | $MAILX -s "${DBINFO}:alert_log:$MESSAGE" ${EMAIL} 
   done 

} 


probeAlertLog() 

{ 

   # Count all Oracle errors - search for string "ORA-" 
   CheckError=`grep "ORA-" $ALERTDIR/$FILE | wc -l` 
   # keep a count of current errors present in the Alert file 
   echo $CheckError >; $LIBDIR/oraErrCount_${SID} 
   # If new errors are detected mail DBA only the last ORA-error Twice 
   if [ $CheckError -ne $LASTCOUNT ] 
   then 
         sendAlertMessage; 
         sendAlertMessage; 
   fi 
} 

probeAlertLog; 
echo Successful completion $0 at `date`. 

-------------------------- 
这个程序调用两个文件, 
一个是  dbinfo.txt 
定义你的数据库。 
192.168.3.3_app1(search) 

另一个是pagers.txt 
zp:rochael@abc.com  BA 
rochael:peng@abc.com BA


标签: mail solaris send

et_highlighter
发表评论 »本文目前尚无任何评论

发表评论

干净网络从你做起,切勿黏贴小广告