Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SHELL script Monitoring oracle alert Log

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Monitor alert Lo

Idea: compare the current last line with the last scanned line according to the alert log line number, which is greater than or equal to the last scanned line from the last scanned line to the last 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-mailTo=737735250@qq.comif [!-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 "no error message was scanned." Echo "" exit 0fiecho "= = $(date" +% Y-%m-%d% H:%M:%S ") scan line ${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 alert"-b $mailTofiecho $endLine > $runfile

The script automatically scans the specified keyword, which in this case is ORA-, and then simply deploys it to crontab.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report