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.Fi leSystemOb ject")
Const intForReading = 1
'create output file
strOutputName = "output.txt"
Set objOut = objFSO.GetFolder(strFolder ).CreateTe xtFile(str OutputName , 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(objFil e.Path, intForReading, False)
'loop thorugh log file
Do While Not objLogFile.AtEndOfStream
strData = Replace(objLogFile.ReadLin e, ",", "")
'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
strFolder = "F:\logs\"
Dim objFSO
Dim objFile
Dim objOut
Set objFSO = CreateObject("Scripting.Fi
Const intForReading = 1
'create output file
strOutputName = "output.txt"
Set objOut = objFSO.GetFolder(strFolder
'for each file in directory
For Each objFile In objFSO.GetFolder(strFolder
'if its a log file
If Right(LCase(objFile.Name),
'open log file
Set objLogFile = objFSO.OpenTextFile(objFil
'loop thorugh log file
Do While Not objLogFile.AtEndOfStream
strData = Replace(objLogFile.ReadLin
'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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.