Once again i need your vital help to fix my issue, please do the needfull.
Issue:- I have schedule one script on windows server to run's every 10 min.(Script do check the alert log file,if database found down it send the email) While i'm doing the database down manually its sending email,
But when its automatically down (By some issue) its not sending the email, I beleive some thing worng in my schedule task, schedule screen shot attached pls help.
Thanks for helping me again Kamaraj, whenever database shutdown or crashes, we have massage in alertlog like "shutdown" and script look for this last fewlines if it is matches send the email. hope you understood my senario.
Thanks for update, i checked in alert log if the database crash its dazen appear the "shutdown" word, Hence I need to add in code extra word "terminated instance".
Can you please help me into this how do i add the extra text in my code?
bold in existing code.
dim WshShell
dim f,fso,Filename
Dim arrFileLines()
Const ForReading = 1
i = 0
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile("C:\\blat182_b\alert.log", 1)
' create the output file here
Set objoutputFile = FSO.CreateTextFile("C:\\blat182_b\result_new.txt")
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
For l = Ubound(arrFileLines)-5 to Ubound(arrFileLines)
' write the output to the file
objoutputFile.writeline arrFileLines(l)
Next
'Close the output file
objoutputFile.close
Filename = "C:\\blat182_b\result_new.txt"
Set f = fso.OpenTextFile(FileName, ForReading, True)
FileText = f.ReadAll
f.close
IF InStr(FileText,"shutdown", "Instance terminated") Then
'Trigger the email - use blat or bmail utility
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\\blat182_b\\mailsend -d xxxx.local -smtp xxx.xxx.xxx.xxx -t xxxx@xx.com, -c xxxx@xx.com -f xx@xxx-xx.xx -sub ""Critical Alert Database not running"" -m message.txt", 1, True
'clear out wshshell variable
set wshShell = Nothing
END IF
WScript.Quit
Mon Apr 30 17:52:16 2012
Completed: ALTER DATABASE DISMOUNT
ARCH: Archiving is disabled
Shutting down archive processes
Archiving is disabled
Archive process shutdown avoided: 0 active
ARCH: Archiving is disabled
Shutting down archive processes
Archiving is disabled
Archive process shutdown avoided: 0 active
Mon Apr 30 18:00:18 2012
Condition 2 Instance terminated:-
KCF: write/open error block=0x440 online=1
file=2 X:\ORACLE\ORADATA\XXXX\UNDOTBS01.DBF
error=27070 txt: 'OSD-04016: Error queuing an asynchronous I/O request.
O/S-Error: (OS 33) The process cannot access the file because another process has locked a portion of the file.'
Fri May 18 11:28:00 2012
Errors in file X:\oracle\admin\XXXx\bdump\XXX_dbw0_5728.trc:
ORA-01242: data file suffered media failure: database in NOARCHIVELOG mode
ORA-01114: IO error writing block to file 2 (block # 1088)
ORA-01110: data file 2: 'X:\ORACLE\ORADATA\XXX\UNDOTBS01.DBF'
ORA-27070: skgfdisp: async read/write failed
OSD-04016: Error queuing an asynchronous I/O request.
O/S-Error: (OS 33) The process cannot access the file because another process has locked a portion of the file.
DBW0: terminating instance due to error 1242
Instance terminated by DBW0, pid = 5728