catch error only 1 week old

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

catch error only 1 week old

#1 Post by flaskvacuum » 16 Mar 2013 22:46

not too sure how to only catch ora- ora that is 1 week old and display them chronologically (with the latest date appear first)
Tue Feb 08 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/OCEAN/udump/ocean_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Feb 09 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/OCEAN/udump/ocean_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Feb 10 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/OCEAN/udump/ocean_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Mon Mar 11 06:08:03 SST 2013
Thread 1 advanced to log sequence 236 (LGWR switch)
Current log# 2 seq# 236 mem# 0: /OCEAN_2/OCEAN/oradata/redo02a.log
Current log# 2 seq# 236 mem# 1: /OCEAN_2/OCEAN/oradata/redo02b.log
Thu Mar 14 00:47:42 SST 2013
Thread 1 advanced to log sequence 237 (LGWR switch)
Current log# 3 seq# 237 mem# 0: /OCEAN_2/OCEAN/oradata/redo03a.log
Current log# 3 seq# 237 mem# 1: /OCEAN_2/OCEAN/oradata/redo03b.log
Tue Mar 17 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/OCEAN/udump/ocean_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []

which in this case i can only catch:

Tue Mar 17 10:47:24 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []

exisitng code with the help from one of our forumers:

Code: Select all

      for /F "delims=" %%a in ('findstr "ORA- SST" "alert_OCEAN.log"') do (
         set tempfile=D:\testScripts\Check_Alert_DB_BKup\tempfile.txt
         set "text=%%a"
         if "!text:~0,4!"=="ORA-" (
         >>"%tempfile%" echo !d8! %%a>>%output-file%
         )
            set d8=%%a
         )


the above code print out all the ORA-error irregardless of the dates.
Last edited by flaskvacuum on 17 Mar 2013 00:07, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: catch error only 1 week old

#2 Post by foxidrive » 16 Mar 2013 23:56

This works here:

Code: Select all

@echo off
setlocal enabledelayedexpansion
      set tempfile=D:\testScripts\Check_Alert_DB_BKup\tempfile.txt
      for /F "delims=" %%a in ('findstr "ORA- SST" "alert_OCEAN.log"') do (
         set "text=%%a"
         if not "!text:ORA-=!"=="!text!" (
         >>"%tempfile%" echo !d8! %%a
         )
            set d8=%%a
         )

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: catch error only 1 week old

#3 Post by flaskvacuum » 17 Mar 2013 00:17

sorry i got to go side way abit.

it seem like the code can't continue to work when the file format is:

Wed Mar 13 21:33:38 SST 2013
Thread 1 advanced to log sequence 430 (LGWR switch)
Current log# 4 seq# 430 mem# 0: /oradata/L1UAT/redo04a.log
Current log# 4 seq# 430 mem# 1: /oradata/L1UAT/redo04b.log
Wed Mar 13 23:23:02 SST 2013
Thread 1 advanced to log sequence 431 (LGWR switch)
Current log# 5 seq# 431 mem# 0: /oradata/L1UAT/redo05a.log
Current log# 5 seq# 431 mem# 1: /oradata/L1UAT/redo05b.log
Tue Mar 12 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/ORL1/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Wed Mar 13 23:23:02 SST 2013
Thread 1 advanced to log sequence 431 (LGWR switch)
Current log# 5 seq# 431 mem# 0: /oradata/L1UAT/redo05a.log
Current log# 5 seq# 431 mem# 1: /oradata/L1UAT/redo05b.log
Tue Mar 12 00:88:88 SST 2013
Errors in file /opt/ora10g/admin/ORL1/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from IOSHUAT.WORLD
ORA-03113: end-of-file on communication channel

the print out become like this:
Tue Mar 12 10:47:24 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 00:88:88 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], [] ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt ORA-02068: following severe error from IOSHUAT.WORLD
ORA-02068: following severe error from IOSHUAT.WORLD ORA-03113: end-of-file on communication channel

not too sure can it be print out as:
Tue Mar 12 10:47:24 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 00:88:88 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from IOSHUAT.WORLD
ORA-03113: end-of-file on communication channel

sharks this is differcult hmmm ..

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: catch error only 1 week old

#4 Post by foxidrive » 17 Mar 2013 00:35

flaskvacuum wrote:the print out become like this:
Tue Mar 12 10:47:24 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 00:88:88 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], [] ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt ORA-02068: following severe error from IOSHUAT.WORLD
ORA-02068: following severe error from IOSHUAT.WORLD ORA-03113: end-of-file on communication channel


Try showing us what you need again. You repeated a part twice it seems.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: catch error only 1 week old

#5 Post by flaskvacuum » 17 Mar 2013 01:27

hmm....did not change the code but changes the file format to test whether it still work with the ORA- error appear on the file format is like this:

Code: Select all

Wed Mar 13 21:33:38 SST 2013
Thread 1 advanced to log sequence 430 (LGWR switch)
  Current log# 4 seq# 430 mem# 0: /oradata/L1UAT/redo04a.log
  Current log# 4 seq# 430 mem# 1: /oradata/L1UAT/redo04b.log
Wed Mar 13 23:23:02 SST 2013
Thread 1 advanced to log sequence 431 (LGWR switch)
  Current log# 5 seq# 431 mem# 0: /oradata/L1UAT/redo05a.log
  Current log# 5 seq# 431 mem# 1: /oradata/L1UAT/redo05b.log
Tue Mar 12 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/ORL1/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Wed Mar 13 23:23:02 SST 2013
Thread 1 advanced to log sequence 431 (LGWR switch)
  Current log# 5 seq# 431 mem# 0: /oradata/L1UAT/redo05a.log
  Current log# 5 seq# 431 mem# 1: /oradata/L1UAT/redo05b.log
Tue Mar 12 00:88:88 SST 2013
Errors in file /opt/ora10g/admin/ORL1/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from IOSHUAT.WORLD
ORA-03113: end-of-file on communication channel 



existing code still:

Code: Select all

for /F "delims=" %%a in ('findstr "ORA- SST" "D:\testScripts\Check_Alert_DB_BKup\alert_OCEAN_test.log"') do (
   set tempfile=D:\testScripts\Check_Alert_DB_BKup\tempfile.txt
   set "text=%%a"
   if "!text:~0,4!"=="ORA-" (
      >>"%tempfile%" echo !d8! %%a>>%output%
   )
      set d8=%%a
   
)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: catch error only 1 week old

#6 Post by foxidrive » 17 Mar 2013 03:21

flaskvacuum wrote:not too sure can it be print out as:
Tue Mar 12 10:47:24 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 00:88:88 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from IOSHUAT.WORLD
ORA-03113: end-of-file on communication channel


So this format is what you want. It was a bit unclear.

Will the lines with ORA-00600 in them always be as above? And every other ORA- error number be listed as the paragraph above?


Can you provide a download location of a larger sample of the log file?

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: catch error only 1 week old

#7 Post by mfm4aa » 17 Mar 2013 05:37

Date and time calculation depends on the local format settings in the system control panel. So you should also provide the output of the command 'echo %date%'.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: catch error only 1 week old

#8 Post by flaskvacuum » 28 Mar 2013 04:57

oh the file format will be like this:

Code: Select all

Wed Mar 13 21:33:38 SST 2013
Thread 1 advanced to log sequence 430 (LGWR switch)
  Current log# 4 seq# 430 mem# 0: /oradata/ocean/redo04a.log
  Current log# 4 seq# 430 mem# 1: /oradata/ocean/redo04b.log
Wed Mar 13 23:23:02 SST 2013
Thread 1 advanced to log sequence 431 (LGWR switch)
  Current log# 5 seq# 431 mem# 0: /oradata/ocean/redo05a.log
  Current log# 5 seq# 431 mem# 1: /oradata/ocean/redo05b.log
Tue Mar 12 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/ocean/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Wed Mar 13 23:23:02 SST 2013
Thread 1 advanced to log sequence 431 (LGWR switch)
  Current log# 5 seq# 431 mem# 0: /oradata/ocean/redo05a.log
  Current log# 5 seq# 431 mem# 1: /oradata/ocean/redo05b.log
Tue Mar 12 00:88:88 SST 2013
Errors in file /opt/ora10g/admin/ocean/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from OCEANUAT.WORLD
ORA-03113: end-of-file on communication channel


wanting to catch all the ora- error from the log file into like below :

Code: Select all

Tue Mar 12 10:47:24 SST 2013 ORA-00600
internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 00:88:88 SST 2013 ORA-00600
internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from IOSHUAT.WORLD
ORA-03113: end-of-file on communication channel


please further advice as i am not sure what is the best way to present the all the ORA-ERROR.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: catch error only 1 week old

#9 Post by foxidrive » 28 Mar 2013 05:51

This is a very simple script that does most of what you need. file.log is the input file.

Code: Select all

@echo off
findstr /v /i /c:"advanced to log sequence" /c:"Current log#" /c:"Errors in file" "file.log" >"file2.log"


This is what it shows, from your sample.

Wed Mar 13 21:33:38 SST 2013
Wed Mar 13 23:23:02 SST 2013
Tue Mar 12 10:47:24 SST 2013
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Wed Mar 13 23:23:02 SST 2013
Tue Mar 12 00:88:88 SST 2013
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from OCEANUAT.WORLD
ORA-03113: end-of-file on communication channel

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: catch error only 1 week old

#10 Post by Aacini » 28 Mar 2013 23:15

@flaskvacuum:

Although you show us your input and output files (4 times!), you had not explained yet what you want, so several doubts exists; for example:

  • Although the topic title say "1 week old" I don't understand if you refer to a date 1 week old from today or anything else. In your example you want in the result the records with these dates: "Tue Mar 12" and "Thu Nov 12" so, how these dates are "1 week old"? My solution show records with "12" in third token (this may be changed if you explain how).
  • In your first data example the records start at a line with "SST" string, and this string is used in your first code example. However, in your last data example the last record "Thu Nov 12 16:16:04 2009" have NOT the SST string! So, how this line is identified as the start of a record? I inserted the SST string in this line in the example data file I used.
  • In first two records the "Errors in file..." line is omitted, but in third record it does not. Why? I assumed that if a record have several ORA- lines, the "Error..." lines must be shown.

Anyway, this is the first version of my solution:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

rem Read all lines from log file
set inRecord=
set numORAs=0
for /F "delims=" %%a in (alert_OCEAN.log) do (
   rem Get tokens 1, 3 and 5 from line
   for /F "tokens=1,3,5" %%b in ("%%a") do (
      set token1=%%b
      set token3=%%c
      set token5=%%d
   )
   rem If this is the starting line of a new record
   if "!token5!" equ "SST" (
      rem Show previous record, if any
      call :showRecord
      rem If this record is a desired one ("1 week old"?)
      if "!token3!" equ "12" (
         rem Start a new record
         set inRecord=0
         set numORAs=0
         rem Show starting line, but keep cursor in same line
         set /P "=%%a" < NUL
      )
   ) else if defined inRecord (
      rem Insert this line in current record
      set /A inRecord+=1
      set "recordLine[!inRecord!]=%%a"
      if "!token1:~0,4!" equ "ORA-" set /A numORAs+=1
   )
)
rem Show last record, if any
call :showRecord
goto :EOF


:showRecord
rem If is there a current record
if defined inRecord (
   rem If is there just one ORA- message
   if %numORAs% lss 2 (
      rem Display first token in same line and rest in next line
      for /F "tokens=1*" %%b in ("!recordLine[%inRecord%]!") do (
         echo  %%b
         echo %%c
      )
   ) else (
      rem Display all record lines in separated lines
      echo/
      for /L %%i in (1,1,%inRecord%) do echo !recordLine[%%i]!
   )
   set inRecord=
)
exit /B

Output:

Code: Select all

Tue Mar 12 10:47:24 SST 2013 ORA-00600:
internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 00:88:88 SST 2013 ORA-00600:
internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Thu Nov 12 16:16:04 SST 2009
Error 2068 trapped in 2PC on transaction 13.4.3724. Cleaning up.
Error stack returned to user:
ORA-02050: transaction 13.4.3724 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from OCEANUAT.WORLD
ORA-03113: end-of-file on communication channel


Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: catch error only 1 week old

#11 Post by foxidrive » 02 Apr 2013 03:58

This is the other thread where you have the same issue. viewtopic.php?p=25268#p25268

If you don't reply to people then they are going to think you are just wasting our time.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: catch error only 1 week old

#12 Post by flaskvacuum » 03 Apr 2013 03:44

tks all for the prompt replies.

let me sort out first.

Post Reply