[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

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
0
rutgermons
Asked:
rutgermons
1 Solution
 
MarcusSjogrenCommented:
Share the folders on the other servers and mount them as network drives. Then use the script in the same way as per above but in the network drive or share.

Example scripts below.

http://stackoverflow.com/questions/631401/access-network-share-from-within-vbscript-eg-filesystemobject

http://ss64.com/vb/drivemap.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now