Shell script monitors Oracle alert logs

Source: Internet
Author: User

Monitoring Alert logs

Idea: Follow the alert journal line number to the current last row and the previous scan row compared to the last scanned row from the previous scan line to scan to the final line

#!/bin/bashscripthome= ' dirname $0 ' scriptname= ' basename $0 ' logdir= $scriptHome/logs#logfile= $logDir/$ scriptname_$ (date  "+%y%m%d"). loglogfile= $logDir/ora-error.logrunfile= $logDir/run.logalertlogfile=/u01/app /oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.logip= ' ifconfig | sed  ' 2q '  | awk - f  ' [ :]+ '   '/inet/{print $4} ' oraerrmsg=ora-[email protected]if [ ! -d   $logDir  ]; then   mkdir -p  $logDirfiif  [ ! -f $ alertlogfile ]; then   echo  "error:  $alertLogFile  no such  File or directory. "    exit 1fitouch  $runfilestartLine =$ (cat  $runfile) endline=$ (cat $ alertlogfile | wc -l) if [  "X$startline"  ==  "x"  ]; then   startline=1else  startline=$ (expr  $startLine  + 1) fiecho  "===  Getting warning log information... "if [  $endLine  -le  $startLine  ]; then   #echo  " Not scanned for error messages. "   echo  "  exit 0fiecho " ===$ (date  "+%y-%m-%d %h:%m:%s")   scan lines ${startline},${endline} ... " >>   $logfile  content= ' cat  $alertLogFile  |  sed -n  "${startline},${endline}p" ' oraerror= ' echo  "$content"  | grep  "$ Oraerrmsg " | tee -a  $logfile ' if [ " X$oraerror " != " x " ];  then echo  "$oraError"  | mutt -s  "$ (date " +%y-%m-%d %h:%m:%s ")   $IP   Warning Log alarms  -b  $mailTofiecho   $endLine  >  $runfile


The script automatically scans for the specified keyword, where it is specified as ora-, and then only needs to be deployed to crontab.


Shell script monitors Oracle alert logs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.