Solved

vbs code to look at logs over different servers

Posted on 2014-03-18
1
188 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

18 Experts available now in Live!

Get 1:1 Help Now