Linux/Unix shell 监控Oracle告警日志(monitor alter log file)
使用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
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The Xiaomi Gaming Monitor G24i has made its global debut, and it's the most affordable option in the new lineup. It has an FHD IPS screen that the company claims is ideal for competitive gamers. The 23.8-inch panel has a 180 Hz refresh rate and 1 ms

Shell scripts use the command interpretation function of Shell to parse a plain text file and then execute these functions. It can also be said that a Shell script is a collection of a series of commands.

Security of Linux Shell Scripting: Avoiding Security Vulnerabilities Introduction: With the popularity and application of Linux operating system, Linux shell script programming has become a very important skill. However, due to the nature and usage of shell scripts, writing unsafe scripts may lead to security vulnerabilities. This article explores how to write secure shell scripts and uses code examples to illustrate how to avoid common security vulnerabilities. 1. Avoid using clear text passwords in shell scripts to avoid

The NitroGS272U M has joined theAcer CS322Qin being introduced as a smart monitor atIFA 2024- however, theformer has the more gamer-like stand of itsGA-seriespredecessors. It also has a smaller 27-inch display - although the glare-free WQHD IPS panel

Monitors can now often be used with extensive setting options and come with their own firmware. A corresponding user interface can be updated as part of firmware updates, for example, and in principle new functions can also be implemented - or bugs c

Dell has just unveiled a new 27-inch IPS gaming monitor with a special and rather useful trick up its sleeve that should appeal to enthusiasts and professional gamers. With the press of a button, the Alienware AW2725QF can switch between two combinat

Samsung's Odyssey gaming monitor line-up features some of the best gaming monitors money can buy, often delivering on top-tier features and specifications along with their flagship pricing. The Odyssey Neo G8 sits at the higher end of Samsung's Odyss

Shell scripts use the command interpretation function of Shell to parse a plain text file and then execute these functions. It can also be said that a Shell script is a collection of a series of commands.
