Automating ORA- Error Alerts from Alert Log in Oracle
Tired of discovering critical ORA- errors too late? Learn how to automate Oracle alert log monitoring with a shell script and email alerts
oracle configurationintermediate
by OracleDba
36 views
Tired of discovering critical ORA- errors too late? Learn how to automate Oracle alert log monitoring with a shell script and email alerts
12
bash
$ORACLE_BASE/diag/rdbms/<DB_UNIQUE_NAME>/<SID>/trace/alert_<SID>.log12345
bash
export ORACLE_SID=ORCL cd $ORACLE_BASE/diag/rdbms/orcl/ORCL/trace ls alert_ORCL.log
bash
ps -ef | grep pmon echo $ORACLE_BASE1234567891011121314151617181920
bash
#!/bin/bash
ORACLE_SID=ORCL
ALERT_LOG="/u01/app/oracle/diag/rdbms/orcl/ORCL/trace/alert_ORCL.log"
TEMP_LOG="/tmp/ora_errors.tmp"
LAST_LOG="/tmp/ora_last_check.log"
EMAIL="
[email protected]
"
HOST=$(hostname)
# If no last log exists, initialize it
if [ ! -f "$LAST_LOG" ]; then
cp "$ALERT_LOG" "$LAST_LOG"
fi
# Capture new lines
NEW_LINES=$(diff "$LAST_LOG" "$ALERT_LOG" | grep ORA-)
if [ ! -z "$NEW_LINES" ]; then
echo "$NEW_LINES" | mail -s "ORA- Error Detected on $HOST - $ORACLE_SID" "$EMAIL"
fi
cp "$ALERT_LOG" "$LAST_LOG"12
bash
*/15 * * * * /home/oracle/scripts/check_alert_log.sh12
bash
logtail -f "$ALERT_LOG" -o /tmp/logtail.state | grep ORA-12
powershell
Get-Content -Path "alert_ORCL.log" -Tail 200 | Select-String "ORA-" | Send-MailMessage ...Please to add comments
No comments yet. Be the first to comment!