Solved

vbs code to look at logs over different servers

Posted on 2014-03-18
1
189 Views
Last Modified: 2014-03-20
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
Comment
Question by:rutgermons
1 Comment
 
LVL 4

Accepted Solution

by:
MarcusSjogren earned 500 total points
ID: 39938372
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short film showing how OnPage and Connectwise integration works.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now