Script to monitor Alert log in Oracle
Alert log monitoring in Oracle
Shell script to monitor alertlog file in Oracle databases on a server . for example if there are 10 databases running on the server ,this script verifies alerts in all those 10 databases. This script can be scheduled in crontab.
Script name: alertlog_mon.sh
calling script: alert_log_mon.sql
#!/bin/ksh #set -x #set -v err() { test -n “$@” && echo “ERROR: $@” >&2 # print error message if given mail_msg=$@ echo $mail_msg >> $LOGFILE} set_env() { umask 177 TIME=`date +%H` export SCRIPT_DIR=/u00/app/oracle/scripts/ALERT_LOG_MON CONN_STR=”sys/abc123 as sysdba” export LOGFILE=$SCRIPT_DIR/alert_log_file_mon.log SQL_FILE=$SCRIPT_DIR/alert_log_mon.sql S_MSG1=”Script to capture errors in alert_log file failed” export V_MAILEES=”dba@ajara.com” export CONTENT=”alert_log_file_mon.log” #PATH=$PATH:$ORACLE_HOME/bin:/usr/ccs/bin: #export PATH=$PATH } main() { set_env for ORACLE_SID in `ps -ef|grep pmon|grep -v grep|grep -v ASM |grep -v root|cut -f3 -d _` #ORACLE_BASE=/u00/app/oracle #export ORAENV_ASK=NO rm -f $LOGFILE mailx -s “${SUBJECT}” $V_MAILEES < $LOGFILE fi done |
SQL file name: alert_log_mon.sql
Copy this SQL file under SCRIPT_DIR . i.e) /u00/app/oracle/scripts/ALERT_LOG_MON
SET TRIMOUT ON SET TRIMSPOOL ON — SET HEADING OFF SET FEEDBACK OFF SET PAUSE OFF SET PAGESIZE 99 SET LINESIZE 800 SET ECHO OFF SET TERM OFF SET VERIFY OFF SET WRAP ON PROMPT PROMPT alert log mon PROMPT ========================== col TABLESPACE_NAME format a35 col FILE_NAME format a75 col AUTOEXTENSIBLE format a7 col BYTES format 999999– alter session set nls_date_format=’dd-mon-yy hh24:mi:ss’ ; spool $LOGFILE |
See also
- Script to get tablespace alert in Oracle
- Script for DB Services and ASM Disk info
- Script to get oracle database status UP or DOWN