SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Parse status log

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Parse status log
Author Message
taso



Joined: 18 May 2007
Posts: 8

Post Parse status log Reply with quote
Hi,

I'm looking for a way to summarize the log file that is generated in the StatusReports directory. I am looking for a single line summary indicating job success or failure, for all jobs run. Currently the log is bloated with many job entries, based on time, and therefore it is useless as a high level view of what is happening on a daily basis.

My goal is to search through the log file and look for keys that occur once per job, "success" for successful jobs and "Aborting" for jobs that fail (those are our keys). Can anyone suggest a script block to do this? Ultimately I would like to find each line that indicates a general job status and write out to a file, convert to html, and save the html file.

Thanks
Wed Jun 20, 2007 1:44 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Reply with quote
The best way to do it is to import schedule.log into some database (it is a tab separated file) and then run a query in the database picking only events you want.
Wed Jun 20, 2007 2:10 pm View user's profile Send private message
taso



Joined: 18 May 2007
Posts: 8

Post Reply with quote
Importing into a db is not really an option that is quick and easy for me to deploy. Here is my loop logic, maybe someone can speak to what I am doing wrong:

Code:

FileOpen( "C:\\24x7\\StatusReports\\SummaryLog.txt", "LineMode", "Write", Append, SummaryLog )
// parse log
FileReadAll( "C:\\24x7\\StatusReports\\testlog.txt", LogFile )

LoopUntil( empty, END_PARSE_LOOP )
// get line
DONE_ERROR:
DONE_SUCCESS:
//   
   GetToken( "\n", LogFile, SummaryLogLine )
       
         // Look for failures
         Match( SummaryLogLine, "ABORTING", has_error )
         IfThen( has_error, WRITE_ERROR )

    // Look for success
         Match( SummaryLogLine, "Success", has_success )
         IfThen( has_success, WRITE_SUCCESS )

IsEqual( SummaryLogLine, "", empty )

END_PARSE_LOOP:

WRITE_ERROR:
SendErrorMsgToLog( SummaryLogLine )
GOTO DONE_ERROR

WRITE_SUCCESS:
SendWarnMsgToLog( SummaryLogLine )
GOTO DONE_SUCCESS



Then end result is that in a test file that has one line with "ABORTING" and one line with "Success", with about five other lines that do not contain any keywords the loop processes the first found match and then writes to the log (for testing; eventually I would output to a file). After the first hit is processed the loop runs through again and although the exit condition ( IsEqual( SummaryLogLine, "", empty ) ) is false as confirmed in the debugger the loop still exits without assessing any further lines in the log. By false I mean that the value for SummaryLogLine is not empty, yet does not contain one of the keywords to view.

The "Send" subroutines are simple script library components that throw items into the log with detail such as ip address, time, etc.

Thoughts?
Wed Jun 20, 2007 2:48 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Reply with quote
Hi,

You cannot jump out of a loop and then return into the loop at the point where you left. You need to move code writing status messages to the loop or move that code into separate functions and call them whining the loop.

Second, the log file can be big. Reading the file thing into memory and then chewing by little pieces is not going to be efficient in JAL. It is better to read file line by line, until the end is reached.

Last, it is probably better to find some utility that can read a log file and filter out only lines containing specific text, for example, you can use free Microsoft Log Parser tool or some port of a Unix awk utility.
Wed Jun 20, 2007 4:17 pm View user's profile Send private message
taso



Joined: 18 May 2007
Posts: 8

Post Reply with quote
Ok thanks, I'll take a look at the LogParser from Microsoft.
Wed Jun 20, 2007 4:48 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.