'****************************************************************************** ' Script to check current status of log files in a given directory ' A parse for interesting information is run. ' Created by Kevin Cooper Nov 08 2005 ' Property of Eclipse Technology Services Ltd http://www.ets.biz '****************************************************************************** '********* Declarations ********* ' Dim FSO, BackUpSuccess, LogFile, OutputFilePath, DaysOfWeek, strFirstInstance, BackupDate, Colour, Output, txtStream Set FSO = CreateObject("Scripting.FileSystemObject") Const LogDir = "C:\BB\tmp\" Const HBLogsDir = "LOGS DIRECTORY HERE" DaysOfWeek = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday") Colour = "green " CreateLog("hbup") '*********** Open log file for writing, call to subroutine ********** Set SearchFolder = FSO.GetFolder(HBLogsDir) Set FileColl = SearchFolder.Files For Each File in FileColl if Right(File.name, 4) = ".log" And File.name <> "System.log" then Set txtStream = fso.Opentextfile(HBLogsDir & File.Name) do while not (txtStream.atEndofStream) text = txtStream.ReadLine & vbCrlf '*** Checks line for search string if (InStr(text,"Status:")>0) or (InStr(text,"Status :")>0) then if (InStr(text, "SUCCEEDED")) then BackUpSuccess = True else BackUpSuccess = False end if end if if (InStr(text,"STATUS OPERATION 0")>0) then for i = 0 to 6 strFirstInstance = InStr(text, DaysOfWeek(i)) if strFirstInstance > 0 then BackupDate = Mid(text, strFirstInstance, Len(Text) - strFirstInstance - 2) end if next end if loop if BackupSuccess then Output = Output & "&green Backup " & File.Name & " was successful on " & BackupDate & vbcrlf else Colour = "red " Output = Output & "&red Backup " & File.Name & " failed on " & BackupDate & vbcrlf end if end if Next ' '############### WRITE FINDINGS TO LOG '############### ' Output = Colour & WeekdayName(Weekday(Now),True) & " " & Mid(Now,1,InStr(Now," ")-1) & " " & TimeValue(Now) & " Backup Status" & vbCrLf & Output Logfile.WriteLine Output LogFile.Close ' Close log file '############### Subroutines ############### Sub CreateLog(txtlog) txtlog = LogDir & txtlog If FSO.FileExists(txtlog) Then Set Logfile = FSO.OpenTextFile(txtlog, 2) Else Set LogFile = FSO.CreateTextFile(txtlog, True) End If End Sub