• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

在solaris下面发送邮件的脚本。

发布: 2007-6-08 22:43 | 作者: seanhe | 来源: | 查看: 39次 | 进入软件测试论坛讨论

领测软件测试网
#!/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          Naresh Puri
# Date            Thu Jun  1 18:01:56 PDT 2000
#-----------------------------------------------------------------------

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
定义你的数据库
61.222.44.67_app1(search)

另一个是pagers.txt
zlx:zlx@chinaunix.net  BA
zlx:peng@chinaunix.net  BA

 C.Arthur 回复于:2004-02-23 20:39:46
此脚本已经过测试

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网