Link to home
Start Free TrialLog in
Avatar of rutgermons
rutgermons

asked on

vbs code to look at logs over different servers

how can I get a vb script to look into log files in different servers in specifc folders for specific values and write to a txt file? the below code looks at 1 folder on 1 server but I need it to look at multiple servers, all help wil do


strFolder = "F:\logs\"
Dim objFSO
Dim objFile
Dim objOut
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
 
 'create output file
 strOutputName = "output.txt"
 Set objOut = objFSO.GetFolder(strFolder).CreateTextFile(strOutputName, True)
 

'for each file in directory
For Each objFile In objFSO.GetFolder(strFolder).Files
        'if its a log file
        If Right(LCase(objFile.Name), 4) = ".log" Then
               'open log file
                Set objLogFile = objFSO.OpenTextFile(objFile.Path, intForReading, False)
                'loop thorugh log file
                Do While Not objLogFile.AtEndOfStream
                        strData = Replace(objLogFile.ReadLine, ",", "")
                        'replace(var,",","")
                        If InStr(strData, "00000000 ManagerAdmin") Or InStr(strData, "The JVM will be terminated") Or InStr(strData, "The JVM will be terminated") then
                                                objOut.WriteLine strData & ", " & objFile.Name & ", " & Date & ", " & Time & ""
                                          end if
                                    end if
                Loop

                objLogFile.Close
                Set objLogFile = Nothing
       
        End If
Next
objOut.Close
ASKER CERTIFIED SOLUTION
Avatar of MarcusSjogren
MarcusSjogren

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial