This is relatively easy to do on a *nix platform, but annoying to do in DOS -- even with a couple of easy-to-find Unix-style tools loaded.
This shell script comes in two parts: the calling script and the
grepping script. The calling script supplies
the names and locations of all your logfiles, and the grepping script
searches each of them for ORA- errors that occurred on the current date.
This shell script requires the following:
Grepping script
echo off
rem
rem *****************************************************************************
rem * log_grep.exe *
rem * *
rem * Takes 1 argument, the logfile fully qualified name *
rem *****************************************************************************
set logfile=%1
set nix=d:\progra~1\unixdos
set gnu=p:\cvs\bin
rem *****************************************************************************
rem * THE AGONY OF WINDOWS DATES *
rem * These manipulations produce a string like 'Thu Nov 08' as in the logfile *
rem * They require the sed script c:\datefix.txt, which changes month number to *
rem * month day, strips the year from the end, changes slashes to spaces, and *
rem * strips trailing spaces. *
rem * They assume that your local date format produces a date \T output like *
rem * Wed 11/14/2001 *
rem *****************************************************************************
for /f "tokens=*" %%1 in ('date /t') do echo %%1 > tmp.txt
%nix%\sed -f d:\tree\datefix.txt tmp.txt > tmp1.txt
for /f "tokens=*" %%1 in ('%nix%\cat tmp1.txt') do set ds=%%1
rem Grep for the line number of the first occurrence of the date in the
logfile
%nix%\grep -n "%ds%" %logfile% | %nix%\head -1 > tmp2.txt
%nix%\sed -e "s#:#|#" -e "s#|.*##" tmp2.txt > tmp3.txt
for /f "tokens=*" %%1 in ('%nix%\cat tmp3.txt') do set ln=%%1
rem Get the last line number in the file
%nix%\grep -n " " %logfile% | %nix%\tail -1 > tmp2.txt
%nix%\sed -e "s#:#|#" -e "s#|.*##" tmp2.txt > tmp3.txt
for /f "tokens=*" %%1 in ('%nix%\cat tmp3.txt') do set lastln=%%1
rem Stick the day's log entries to date in a temp file and grep for ORA
errors
%nix%\getlines %ln% %lastln% %logfile% > tmp.txt
%gnu%\grep -B3 "ORA-" tmp.txt
del tmp*.txt
Calling script
Modify this script with the names of your monitored instances and logfiles.
After it's finished repeatedly calling
log_grep.bat
, it will pop open a Notepad window with the output.
set myfile1=\\myserver1\c$\oracle\ora81\admin\bdump\trn4\trn4alrt.log set myfile2=\\myserver2\d$\oracle\ora81\admin\trn3\bdump\trn3alrt.log set myfile3=\\myserver3\c$\orant\admin\trn2\bdump\trn2alrt.log echo off for /f "tokens=*" %%1 in ('date /t') do set dst=%%1 echo Errors for %dst% > log_err.txt for /f "tokens=*" %%1 in ('time /t') do set dst=%%1 echo as of %dst% >> log_err.txt echo ------------------------------------------------------------ >> log_err.txt echo MYINSTANCE1 >> log_err.txt call d:\log_grep.bat %myfile1% >> log_err.txt echo ------------------------------------------------------------ >> log_err.txt echo MYINSTANCE2 >> log_err.txt call d:\tree\log_grep.bat %myfile2% >> log_err.txt echo ------------------------------------------------------------ >> log_err.txt echo MYINSTANCE3 >> log_err.txt call d:\tree\log_grep.bat %myfile3% >> log_err.txt echo ------------------------------------------------------------ >> log_err.txt notepad log_err.txt