Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strebor Read Hear.... LogParser

Status
Not open for further replies.
Apr 5, 2005
1,484
US
strebor (TechnicalUser)
26 Jun 06 10:56
You may be interested in Log Parser 2.2, free from Microsoft, is a really good tool for accessing and reporting on log files, including event logs. It can be used as a command line tool or called and used from a script (vbscript, etc.) or a programming language such as c#. You can easily construct sql-like queries... more at:
strebor,
I like the product and I have tested it getting remote Event log errors(FROM \\Fileserver\System). Works Great...
In my VBScript I have an arrComputers (array) created via a text file. How would I allow the SELECT Query in LogParser to enclude the server name in the FROM_Entity
Example: FROM \\Servername\System, but instead of manually entering in every server name it reads it from arrComputers.

If anyone knows please reply, looking at the Log Parser Forum for the answer.

Here is the VB Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\Scripts\Server.txt", ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
arrComputers = Split(strText, VbCrLf)

For Each strComputer In arrComputers

Set objLogQuery = CreateObject("MSUtil.LogQuery")

Set objEVTInputFormat = CreateObject("MSUtil.LogQuery.EventLogInputFormat")
objEVTInputFormat.direction = "BW"


Set objNATOutputFormat = CreateObject("MSUtil.LogQuery.NativeOutputFormat")
objNATOutputFormat.rtp = -1

strQuery = "SELECT TimeWritten AS TIME, EventTypeName AS EVENT, EventID, TO_UPPERCASE( EXTRACT_PREFIX(Message, 4, ' ') ) AS DESCRIPTION FROM \\hpmidb1\System WHERE ( EventTypeName = 'Error event') AND TimeWritten >= SUB ( TO_LOCALTIME(SYSTEM_TIMESTAMP()), TIMESTAMP('0000-01-05', 'yyyy-MM-dd') )"


objLogQuery.ExecuteBatch strQuery, objEVTInputFormat, objNATOutputFormat

Next
 
...AS DESCRIPTION FROM \\" & strComputer & "\System WHERE...

I didn't see your post until today, so you've probably already got the answer.

strebor
 
Yes, I was able to get my quotes in the right place.

Script is running great...

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top