Linux/Unix shell 监控Oracle告警日志(monitor alter log file)

php中文网
发布: 2016-06-07 17:26:28
原创
1439人浏览过

使用shell脚本实现对Oracle数据库的监控与管理将大大简化DBA的工作负担,如常见的对实例的监控,监听的监控,告警日志的监控,以

使用shell脚本实现对oracle数据库的监控与管理将大大简化dba的工作负担,如常见的对实例的监控,监听的监控,告警日志的监控,,以及数据库的备份,awr report的自动邮件等。本文给出linux 下使用 shell 脚本来监控 oracle 告警日志(monitor alter log file)。

Linux Shell的相关参考:

Linux/Unix shell 脚本中调用SQL,RMAN脚本

Linux/Unix shell sql 之间传递变量

Linux Unix shell 调用 PL/SQL

1、监控Oracle告警日志脚本

robin@SZDB:~/dba_scripts/custom/bin> more ck_alert.sh
#!/bin/bash
# --------------------------------------------------------------------------+
#                  CHECK ALERT LOG FILE                                    |
#  Filename: ck_alert.sh                                                  |
#  Desc:                                                                  |
#      The script use to check alert log file.                            |
#      Once any error was caught, a mail alert will be sent.              | 
#      Deploy it by crontab. e.g. per 15 min                              | 
#  Usage:                                                                  |
#      ./ck_alert.sh $ORACLE_SID                                          | 
#                                                                          |
#  Author : Robinson                                                      |
#  Blog  : 0612                            |
# --------------------------------------------------------------------------+
#
# --------------------------
#  Check SID
# --------------------------

if [ -z "${1}" ];then
    echo "Usage: "
    echo "      `basename $0` ORACLE_SID"
    exit 1
fi

# -------------------------------
#  Set environment here
# ------------------------------

if [ -f ~/.bash_profile ]; then
    . ~/.bash_profile
fi

可设置日志状态效果的日历
可设置日志状态效果的日历

可设置日志状态效果的日历

可设置日志状态效果的日历 52
查看详情 可设置日志状态效果的日历

export ORACLE_SID=$1
export MACHINE=`hostname`
export MAIL_DIR=/users/robin/dba_scripts/sendEmail-v1.56
export MAIL_LIST='Robinson.chen@12306.com'
export MAIL_FM='oracle@szdb.com'

# ----------------------------------------------
# check the database is running, if not exit
# ----------------------------------------------

db_stat=`ps -ef | grep pmon_$ORACLE_SID | grep -v grep| cut -f3 -d_`
if [ -z "$db_stat" ]; then
    date >/tmp/db_${ORACLE_SID}_stauts.log
    echo " $ORACLE_SID is not available on ${MACHINE} !!!" >>/tmp/db_${ORACLE_SID}_stauts.log
    MAIL_SUB=" $ORACLE_SID is not available on ${MACHINE} !!!"
    $MAIL_DIR/sendEmail -u $MAIL_SUB -f $MAIL_FM -t $MAIL_LIST -o message-file=/tmp/db_${ORACLE_SID}_stauts.log
    exit 1
fi;

# --------------------------------------
#  Get the location of alert log file
# --------------------------------------

sqlplus '/ as sysdba' /tmp/${ORACLE_SID}_monitor_temp.txt
column xxxx format a10
column value format a80
set lines 132
SELECT 'xxxx' ,value FROM  v\$parameter WHERE  name = 'background_dump_dest'
/
exit
EOF

cat /tmp/${ORACLE_SID}_monitor_temp.txt | awk '$1 ~ /xxxx/ {print $2}' > /tmp/${ORACLE_SID}_monitor_location.txt
read ALERT_DIR rm /tmp/${ORACLE_SID}_monitor_temp.txt 2>/dev/null

# ----------------------------------------
#  Define archive directory and log file
# ----------------------------------------

DT=`date +%Y%m%d`
DT_DIR=`date +%Y%m`
ARCH_DIR=${ALERT_DIR}/${DT_DIR}

if [ ! -d "${ARCH_DIR}" ] ; then
    mkdir $ARCH_DIR
fi

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号