Sign in to follow this  
Followers 0
Qual-IT London

Logparser

6 posts in this topic

Hey

I am using an autoit script and the logparser tool to make a server monitor that we want to sell with our servers.

All works nicely except im wondering if AutoIT can read the event logs itself rather than using logparser as I doubt I am allowed to sell logparser even tho its indirectly.

Tks

N

Share this post


Link to post
Share on other sites



how is the log layed out? and in what format

cuz if all lines are logged the same then yeah you could use autoit to parse it but yeah u just need the layout, and the order u want it to be in after its parsed

Share this post


Link to post
Share on other sites

Sure it can.

Here is something I just wrote (With the help of randallc) that parses my flow cytometry data.

Download the the logfile I attached to this thread, and run this script. (Requires beta)

It will read and parse the log file for the info I want, and output a nice, pretty excel file.

-Simucal

;filereader.au3; randallc
#include"ExcelCom.au3"
#include"Array2s.au3"; use for $ar2_Array=_Array2DCreateFromArray($ar_Final )/_Array2dDisplay($ar2_Array, "Sorted", 0)
#include"Array2Ds.au3"; use for $ar2_Array=_Array2DCreateFromArray($ar_Final )/_Array2dDisplay($ar2_Array, "Sorted", 0)
#include <GUIConstants.au3>
#include <File.au3>
;and for _ArrayViewText($ar2_Array, 'Display')
;local $ar_Final[1],$r,$s_Split=" "; $s_Split=@tab
local $ar_Final[1],$r,$s_Split=@tab
MsgBox(0,"FlowParser - Instructions","Step 1:" & @CRLF & "First you must select your exported CellQuest Pro Statistics File.")
$Txtfile=FileOpenDialog("Select CellQuest Pro Statistics File.",@ScriptDir,"All (*.*)")
If @error Then
    MsgBox(48,"FlowParser","You must select a CellQuest Pro statistics file!")
    Exit
EndIf
MsgBox(0,"FlowParser - Instructions","Step 2:" & @CRLF & "Now you must name the Excel file you wish to export the statistics to.")
$FilePath=FileSaveDialog( "Choose a name for the Excel file.", @ScriptDir, "Excel (*.xls)")
If @error Then
    MsgBox(48,"FlowParser","You must specify a name for the Excel file to be created!")
    Exit
EndIf
If StringLower(StringRight($FilePath,4)) <> ".xls" Then
    $FilePath = $FilePath & ".xls"
EndIf
$ShortFilePathArray = StringSplit($FilePath,"\")
$ShortFilePath = _ArrayPop($ShortFilePathArray)

$ReadFile=FileOpen($Txtfile,0); Open the log file

$count = FileRead($Txtfile) ; count the number of lines in this weird file.
$count = StringSplit($count,@CR,1)
$count = (100/((($count[0])-2)/11))
$Progress = $count

$Line=FileReadLine($ReadFile);read first line which is not needed; then ignore

ProgressOn("FlowParser - Progress", "Parsing Flow Cytometry Data")
while 1
    $Line=FileReadLine($ReadFile); read line1 of each 11; if not exists, exit; send line 1 to the func for processing
    If @error = -1 Then ExitLoop
    $r+=1
    redim $ar_Final[ubound($ar_Final)+1]; every extra line of results needs array to be increased dimension to accept extra
    $ar_Final[$r]=_Read11Lines($ReadFile,$Line,$s_Split); call the func to process the next 11 lines of text file
;MsgBox(0,"","$ar_Final[$r]="&$ar_Final[$r])
    ProgressSet($Progress,"Saving data to " & $ShortFilePath & "...")
    $Progress = $Progress + $Count
    sleep(50)
WEnd
ProgressOff()
FileClose($Txtfile)
;_ArrayDisplay($ar_Final,"")
_ArrayDelete($ar_Final,0);([0]) element not needed
$ar2_Array=_Array2DCreateFromArray($ar_Final );#include"Array2s.au3"; use from my UDF to change 1D array of lines ("|" delimited)
;to 2D array
_Array2dDisplay($ar2_Array, "FlowParser - Raw Cytometry Data", 0);#include"Array2s.au3"; change back to 1D array only tempoirary for quick view
;_ArrayViewText($ar2_Array, 'FlowParser - Raw Cytometry Data');#include"Array2Ds.au3"; better 2D array viewer; try it!
_Array2DTranspose( $ar2_Array);? needed before transfer to XL?;#include"Array2s.au3" [Excel arrays are the other way round?]
$XLArrayAddress=_XLArrayWrite($ar2_Array,$FilePath,1,"A6",1);not tested yet
$XL=_XLWrite($FilePath,1,"G",3,"%Gated",0)
$XL=_XLWrite($FilePath,1,"H",3,"%Gated",0)
$XL=_XLWrite($FilePath,1,"G",4,"Data analysis",0)
$XL=_XLWrite($FilePath,1,"F",5,"Remarks",0)
$XL=_XLWrite($FilePath,1,"G",5,"% FL1",0)
$XL=_XLWrite($FilePath,1,"H",5,"% FL2",0)
$XL=_XLWrite($FilePath,1,"I",5,"Mean, FL1",0)
$XL=_XLWrite($FilePath,1,"J",5,"Mean, FL2",0)
$XL=_XLSetColumnWidth($FilePath,1,"A:J","Autofit",0)
$XL=_XLSetCellFontColor($FilePath,1,"C",8,5,0)
_XLClose($FilePath,1)
exit
;===================================================================================================


func _Read11Lines($ReadFile,$Line,$s_Split)
    local $n=1; line counter
    $ar_Temp=StringSplit($Line,$s_Split); split first log file line of the 11 into a temp array
    $ar_Fix=StringSplit($ar_Temp[2],"."); split the 2nd string to get Mouse Type
    $ar_Fix2=StringSplit($ar_Fix[2],"-"); split the 2nd string again to get Organ Type
    $ar_Temp[2]=$ar_Fix[1]&" / "&$ar_Fix2[1]; Combine them i.e. DBA / LN
    $s_Needed=$r&"|"&$ar_Temp[1]&"|"&$ar_Temp[2]; start building pipe - delimited string to return to the main script for this 11 lines
;MsgBox(0,"","$s_Needed="&$s_Needed)
    while $n<11
        $n+=1
        $Line=FileReadLine($ReadFile)
        If @error = -1 Then
            MsgBox(0,"","Error, not 11 lines?")
            ExitLoop
        EndIf
        if $n=2 then; for line 2 of 11
            $ar_Temp=StringSplit($Line,$s_Split); split nth log file line of the 11 into a temp array
            $ar_Temp[7]=StringTrimLeft($ar_Temp[7],6); Remove FL1-H
            $ar_Temp[7]=StringTrimRight($ar_Temp[7],6); Remove (Log)
            $ar_Temp[8]=StringTrimLeft($ar_Temp[8],6); Remove Fl2-H
            $ar_Temp[8]=StringTrimRight($ar_Temp[8],6); Remove (Log)            
            $s_Needed&="|"&$ar_Temp[7]&"|"&$ar_Temp[8]&"|"; add to pipe - delimited string
        EndIf
        if $n=8 then; for line 8 of 11
            $ar_Temp=StringSplit($Line,$s_Split); split nth log file line of the 11 into a temp array
            $s_Needed&="|"&$ar_Temp[14]; add to pipe - delimited string
            $s_Delay=$ar_Temp[16]; keep out-of sequence for next string add as "$s_Delay"
        EndIf
        if $n=11 then; for line 11 of 11
            $ar_Temp=StringSplit($Line,$s_Split); split nth log file line of the 11 into a temp array
            $s_Needed&="|"&$ar_Temp[14] &"|"&$s_Delay&"|"&$ar_Temp[16]; add to pipe - delimited string; include "$s_Delay"
        EndIf
    ;MsgBox(0,"","$s_Needed="&$s_Needed)
    WEnd
    return $s_Needed; return building pipe - delimited string to return to the main script for this 11 lines
EndFunc  ;==>_Read11Lines

LogFile.txt


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Sure it can.

Here is something I just wrote (With the help of randallc) that parses my flow cytometry data.

Download the the logfile I attached to this thread, and run this script. (Requires beta)

It will read and parse the log file for the info I want, and output a nice, pretty excel file.

-Simucal

;filereader.au3; randallc
#include"ExcelCom.au3"
#include"Array2s.au3"; use for $ar2_Array=_Array2DCreateFromArray($ar_Final )/_Array2dDisplay($ar2_Array, "Sorted", 0)
#include"Array2Ds.au3"; use for $ar2_Array=_Array2DCreateFromArray($ar_Final )/_Array2dDisplay($ar2_Array, "Sorted", 0)
#include <GUIConstants.au3>
#include <File.au3>
;and for _ArrayViewText($ar2_Array, 'Display')
;local $ar_Final[1],$r,$s_Split=" "; $s_Split=@tab
local $ar_Final[1],$r,$s_Split=@tab
MsgBox(0,"FlowParser - Instructions","Step 1:" & @CRLF & "First you must select your exported CellQuest Pro Statistics File.")
$Txtfile=FileOpenDialog("Select CellQuest Pro Statistics File.",@ScriptDir,"All (*.*)")
If @error Then
    MsgBox(48,"FlowParser","You must select a CellQuest Pro statistics file!")
    Exit
EndIf
MsgBox(0,"FlowParser - Instructions","Step 2:" & @CRLF & "Now you must name the Excel file you wish to export the statistics to.")
$FilePath=FileSaveDialog( "Choose a name for the Excel file.", @ScriptDir, "Excel (*.xls)")
If @error Then
    MsgBox(48,"FlowParser","You must specify a name for the Excel file to be created!")
    Exit
EndIf
If StringLower(StringRight($FilePath,4)) <> ".xls" Then
    $FilePath = $FilePath & ".xls"
EndIf
$ShortFilePathArray = StringSplit($FilePath,"\")
$ShortFilePath = _ArrayPop($ShortFilePathArray)

$ReadFile=FileOpen($Txtfile,0); Open the log file

$count = FileRead($Txtfile); count the number of lines in this weird file.
$count = StringSplit($count,@CR,1)
$count = (100/((($count[0])-2)/11))
$Progress = $count

$Line=FileReadLine($ReadFile);read first line which is not needed; then ignore

ProgressOn("FlowParser - Progress", "Parsing Flow Cytometry Data")
while 1
    $Line=FileReadLine($ReadFile); read line1 of each 11; if not exists, exit; send line 1 to the func for processing
    If @error = -1 Then ExitLoop
    $r+=1
    redim $ar_Final[ubound($ar_Final)+1]; every extra line of results needs array to be increased dimension to accept extra
    $ar_Final[$r]=_Read11Lines($ReadFile,$Line,$s_Split); call the func to process the next 11 lines of text file
;MsgBox(0,"","$ar_Final[$r]="&$ar_Final[$r])
    ProgressSet($Progress,"Saving data to " & $ShortFilePath & "...")
    $Progress = $Progress + $Count
    sleep(50)
WEnd
ProgressOff()
FileClose($Txtfile)
;_ArrayDisplay($ar_Final,"")
_ArrayDelete($ar_Final,0);([0]) element not needed
$ar2_Array=_Array2DCreateFromArray($ar_Final );#include"Array2s.au3"; use from my UDF to change 1D array of lines ("|" delimited)
;to 2D array
_Array2dDisplay($ar2_Array, "FlowParser - Raw Cytometry Data", 0);#include"Array2s.au3"; change back to 1D array only tempoirary for quick view
;_ArrayViewText($ar2_Array, 'FlowParser - Raw Cytometry Data');#include"Array2Ds.au3"; better 2D array viewer; try it!
_Array2DTranspose( $ar2_Array);? needed before transfer to XL?;#include"Array2s.au3" [Excel arrays are the other way round?]
$XLArrayAddress=_XLArrayWrite($ar2_Array,$FilePath,1,"A6",1);not tested yet
$XL=_XLWrite($FilePath,1,"G",3,"%Gated",0)
$XL=_XLWrite($FilePath,1,"H",3,"%Gated",0)
$XL=_XLWrite($FilePath,1,"G",4,"Data analysis",0)
$XL=_XLWrite($FilePath,1,"F",5,"Remarks",0)
$XL=_XLWrite($FilePath,1,"G",5,"% FL1",0)
$XL=_XLWrite($FilePath,1,"H",5,"% FL2",0)
$XL=_XLWrite($FilePath,1,"I",5,"Mean, FL1",0)
$XL=_XLWrite($FilePath,1,"J",5,"Mean, FL2",0)
$XL=_XLSetColumnWidth($FilePath,1,"A:J","Autofit",0)
$XL=_XLSetCellFontColor($FilePath,1,"C",8,5,0)
_XLClose($FilePath,1)
exit
;===================================================================================================


func _Read11Lines($ReadFile,$Line,$s_Split)
    local $n=1; line counter
    $ar_Temp=StringSplit($Line,$s_Split); split first log file line of the 11 into a temp array
    $ar_Fix=StringSplit($ar_Temp[2],"."); split the 2nd string to get Mouse Type
    $ar_Fix2=StringSplit($ar_Fix[2],"-"); split the 2nd string again to get Organ Type
    $ar_Temp[2]=$ar_Fix[1]&" / "&$ar_Fix2[1]; Combine them i.e. DBA / LN
    $s_Needed=$r&"|"&$ar_Temp[1]&"|"&$ar_Temp[2]; start building pipe - delimited string to return to the main script for this 11 lines
;MsgBox(0,"","$s_Needed="&$s_Needed)
    while $n<11
        $n+=1
        $Line=FileReadLine($ReadFile)
        If @error = -1 Then
            MsgBox(0,"","Error, not 11 lines?")
            ExitLoop
        EndIf
        if $n=2 then; for line 2 of 11
            $ar_Temp=StringSplit($Line,$s_Split); split nth log file line of the 11 into a temp array
            $ar_Temp[7]=StringTrimLeft($ar_Temp[7],6); Remove FL1-H
            $ar_Temp[7]=StringTrimRight($ar_Temp[7],6); Remove (Log)
            $ar_Temp[8]=StringTrimLeft($ar_Temp[8],6); Remove Fl2-H
            $ar_Temp[8]=StringTrimRight($ar_Temp[8],6); Remove (Log)            
            $s_Needed&="|"&$ar_Temp[7]&"|"&$ar_Temp[8]&"|"; add to pipe - delimited string
        EndIf
        if $n=8 then; for line 8 of 11
            $ar_Temp=StringSplit($Line,$s_Split); split nth log file line of the 11 into a temp array
            $s_Needed&="|"&$ar_Temp[14]; add to pipe - delimited string
            $s_Delay=$ar_Temp[16]; keep out-of sequence for next string add as "$s_Delay"
        EndIf
        if $n=11 then; for line 11 of 11
            $ar_Temp=StringSplit($Line,$s_Split); split nth log file line of the 11 into a temp array
            $s_Needed&="|"&$ar_Temp[14] &"|"&$s_Delay&"|"&$ar_Temp[16]; add to pipe - delimited string; include "$s_Delay"
        EndIf
;MsgBox(0,"","$s_Needed="&$s_Needed)
    WEnd
    return $s_Needed; return building pipe - delimited string to return to the main script for this 11 lines
EndFunc ;==>_Read11Lines

I think the windows Event Log is slightly different, not to mention the .evt files are open by the OS all the time!

Has anyone done this?

Share this post


Link to post
Share on other sites

I wasnt implying that this script would work for you :think:. It was answering your question as to whether it was possible to parse a log file. And providing an example with some methods.


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

What about using the dumpel.exe in conjunction with AutoIt?

http://www.windowsnetworking.com/nt/atips/atips54.shtml


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0