<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Prune_log.py</id>
	<title>Prune log.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Prune_log.py"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Prune_log.py&amp;action=history"/>
	<updated>2026-05-18T12:42:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Prune_log.py&amp;diff=3084&amp;oldid=prev</id>
		<title>PeterHarding at 06:03, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Prune_log.py&amp;diff=3084&amp;oldid=prev"/>
		<updated>2009-07-19T06:03:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:03, 19 July 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l551&quot;&gt;Line 551:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 551:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Examples]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Log Analysis]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Log Analysis]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Prune_log.py&amp;diff=2168&amp;oldid=prev</id>
		<title>PeterHarding: New page: &lt;pre&gt; #! /usr/bin/env python # #  Purpose: Parse and display an informix log file # #  $Id:$ # #---------------------------------------------------------------------  &quot;&quot;&quot; Parse Ben Lee&#039;s L...</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Prune_log.py&amp;diff=2168&amp;oldid=prev"/>
		<updated>2008-05-24T07:35:15Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;lt;pre&amp;gt; #! /usr/bin/env python # #  Purpose: Parse and display an informix log file # #  $Id:$ # #---------------------------------------------------------------------  &amp;quot;&amp;quot;&amp;quot; Parse Ben Lee&amp;#039;s L...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#! /usr/bin/env python&lt;br /&gt;
#&lt;br /&gt;
#  Purpose: Parse and display an informix log file&lt;br /&gt;
#&lt;br /&gt;
#  $Id:$&lt;br /&gt;
#&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Parse Ben Lee&amp;#039;s LR log files to show the underlying function&lt;br /&gt;
invocation sequence in the designated log file. &lt;br /&gt;
&lt;br /&gt;
Another option shows timing of start of function.&lt;br /&gt;
&lt;br /&gt;
Instructions for use:&lt;br /&gt;
&lt;br /&gt;
1.  You should change to the loadgen directory - the one containing the log files generated by Ben&amp;#039;s code.&lt;br /&gt;
&lt;br /&gt;
2.  Run:&lt;br /&gt;
&lt;br /&gt;
       $ prune_log.py -t *.log&lt;br /&gt;
&lt;br /&gt;
    This produces a logs.sorted file contining the merged and sorted rewritten logs.&lt;br /&gt;
&lt;br /&gt;
3.  Then run:&lt;br /&gt;
&lt;br /&gt;
       $ time_line.py&lt;br /&gt;
&lt;br /&gt;
    This produces &amp;#039;time_line.txt&amp;#039; which contains the time line and concurrency map.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
import re&lt;br /&gt;
import os&lt;br /&gt;
import sys&lt;br /&gt;
import glob&lt;br /&gt;
import time&lt;br /&gt;
import getopt&lt;br /&gt;
import pickle&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
__version__  = &amp;quot;1.2.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
debugFlg     = 0&lt;br /&gt;
stdoutFlg    = 0&lt;br /&gt;
verboseFlg   = 0&lt;br /&gt;
wallclockFlg = 0&lt;br /&gt;
rewriteFlg   = 0&lt;br /&gt;
directoryFlg = None&lt;br /&gt;
&lt;br /&gt;
filename     = &amp;quot;Backline_0068.log&amp;quot;&lt;br /&gt;
mode         = None&lt;br /&gt;
data         = None&lt;br /&gt;
t_start      = None&lt;br /&gt;
td_start     = None&lt;br /&gt;
vuser        = &amp;quot;068&amp;quot;&lt;br /&gt;
node_map     = {}&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
addresses    = {}&lt;br /&gt;
user_threads = {}&lt;br /&gt;
locks        = {}&lt;br /&gt;
transactions = {}&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
class Lock:&lt;br /&gt;
   address   = None&lt;br /&gt;
   wtlist    = None&lt;br /&gt;
   owner     = None&lt;br /&gt;
   lklist    = None&lt;br /&gt;
   type      = None&lt;br /&gt;
   tblsnum   = None&lt;br /&gt;
   rowid     = None&lt;br /&gt;
   key_no    = None&lt;br /&gt;
   bsize     = None&lt;br /&gt;
&lt;br /&gt;
   def __init__(self, p):&lt;br /&gt;
      print &amp;quot;XXXX&amp;quot;, p&lt;br /&gt;
      self.address   = p[0]&lt;br /&gt;
      self.wtlist    = p[1]&lt;br /&gt;
      self.owner     = p[2]&lt;br /&gt;
      self.lklist    = p[3]&lt;br /&gt;
      self.type      = p[4]&lt;br /&gt;
      self.tblsnum   = p[5]&lt;br /&gt;
      self.rowid     = p[6]&lt;br /&gt;
      self.key_no    = p[7]&lt;br /&gt;
      self.bsize     = p[8]&lt;br /&gt;
&lt;br /&gt;
   def Check(self, p):&lt;br /&gt;
      pass&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def startSeconds(s):&lt;br /&gt;
   return time.mktime(time.strptime(s, &amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def seconds(hms):&lt;br /&gt;
   s = hms.split(&amp;#039;:&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
   return ((s[0] * 60) + s[1]) * 60 + s[2]&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def hms(t_secs):&lt;br /&gt;
   hm     = t_secs / 60&lt;br /&gt;
   hours  = hm / 60&lt;br /&gt;
   mins   = hm % 60&lt;br /&gt;
   secs   = t_secs % 60&lt;br /&gt;
&lt;br /&gt;
   return &amp;quot;%02d:%02d:%02d&amp;quot; % ( hours, mins, secs)&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def parse(filename):&lt;br /&gt;
   global t_start&lt;br /&gt;
&lt;br /&gt;
   print filename&lt;br /&gt;
&lt;br /&gt;
   tmatch = re.search(r&amp;#039;(.*?).log&amp;#039;, filename)&lt;br /&gt;
   if tmatch:&lt;br /&gt;
      name = tmatch.group(1)&lt;br /&gt;
   else:&lt;br /&gt;
      name = filename + &amp;quot;.log&amp;quot;&lt;br /&gt;
      filename += &amp;quot;.log&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   if rewriteFlg:&lt;br /&gt;
      outfile = name + &amp;quot;.out&amp;quot;&lt;br /&gt;
   else:&lt;br /&gt;
      outfile = name + &amp;quot;.seq&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   tmatch = re.search(r&amp;#039;line_(.*?).log&amp;#039;, filename)&lt;br /&gt;
   if tmatch:&lt;br /&gt;
      vuser_id = int(tmatch.group(1))&lt;br /&gt;
   else:&lt;br /&gt;
      vuser_id = 0&lt;br /&gt;
&lt;br /&gt;
   vuser = &amp;quot;%03d&amp;quot; % vuser_id&lt;br /&gt;
&lt;br /&gt;
   try:&lt;br /&gt;
      ifo = open(filename, &amp;#039;r&amp;#039;)&lt;br /&gt;
   except IOError, msg:&lt;br /&gt;
      sys.stderr.write(filename + &amp;#039;: cannot open: &amp;#039; + `msg` + &amp;#039;\n&amp;#039;)&lt;br /&gt;
      sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
   if stdoutFlg == 1:&lt;br /&gt;
      ofo = sys.stdout&lt;br /&gt;
   else:&lt;br /&gt;
      try:&lt;br /&gt;
         ofo = open(outfile, &amp;#039;w&amp;#039;)&lt;br /&gt;
      except IOError, msg:&lt;br /&gt;
         sys.stderr.write(outfile + &amp;#039;: cannot open: &amp;#039; + `msg` + &amp;#039;\n&amp;#039;)&lt;br /&gt;
         sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
   cnt = 0&lt;br /&gt;
&lt;br /&gt;
   username      = &amp;quot;*UNDEF*&amp;quot;&lt;br /&gt;
   current_task  = None&lt;br /&gt;
   end_iteration = 0&lt;br /&gt;
   t_offset      = None&lt;br /&gt;
   endFlg        = 0&lt;br /&gt;
   obj           = &amp;quot;-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   while 1:&lt;br /&gt;
&lt;br /&gt;
      line = ifo.readline()&lt;br /&gt;
&lt;br /&gt;
      if not line: break&lt;br /&gt;
&lt;br /&gt;
      line = line[:-1]&lt;br /&gt;
      line = line.replace(&amp;quot;\r&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;^[^0-9]&amp;quot;, line):&lt;br /&gt;
         continue&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;^#&amp;quot;, line):&lt;br /&gt;
         continue&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;^$&amp;quot;, line):&lt;br /&gt;
         continue&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;^\r$&amp;quot;, line):&lt;br /&gt;
         continue&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;initial due date time&amp;quot;, line):&lt;br /&gt;
         continue&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;username&amp;quot;, line):&lt;br /&gt;
         tmatch = re.search(r&amp;#039;host \[(.*?):7001\] username \[(.*?)\]&amp;#039;, line)&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            node     = tmatch.group(1)&lt;br /&gt;
            username = tmatch.group(2)&lt;br /&gt;
            print &amp;quot;Username  = \&amp;quot;%s\&amp;quot;&amp;quot; % username&lt;br /&gt;
            print &amp;quot;Node      = \&amp;quot;%s\&amp;quot; (vuser %s)&amp;quot; % (node, vuser)&lt;br /&gt;
            node_map[vuser] = node&lt;br /&gt;
         continue&lt;br /&gt;
&lt;br /&gt;
      if not t_offset:&lt;br /&gt;
         if re.search(&amp;quot;Timestamp&amp;quot;, line):&lt;br /&gt;
            tmatch = re.search(r&amp;#039;Timestamp \((.*?)\)&amp;#039;, line)&lt;br /&gt;
            if tmatch:&lt;br /&gt;
               t_timestamp = int(tmatch.group(1))&lt;br /&gt;
               print &amp;quot;Timestamp = \&amp;quot;%d\&amp;quot;&amp;quot; % t_timestamp&lt;br /&gt;
               if t_start:&lt;br /&gt;
                  t_offset = t_timestamp - t_start&lt;br /&gt;
               else:&lt;br /&gt;
                  t_start = t_timestamp&lt;br /&gt;
                  print &amp;quot;Setting t_start = \&amp;quot;%d\&amp;quot;&amp;quot; % t_start&lt;br /&gt;
                  t_offset = 0&lt;br /&gt;
               print &amp;quot;Delta     = \&amp;quot;%d\&amp;quot;&amp;quot; % t_offset&lt;br /&gt;
               continue&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      cnt += 1&lt;br /&gt;
&lt;br /&gt;
      if re.search(&amp;quot;TxEnd&amp;quot;, line):&lt;br /&gt;
         endFlg = 1&lt;br /&gt;
&lt;br /&gt;
      p = line.split(&amp;#039; &amp;#039;, 5)&lt;br /&gt;
&lt;br /&gt;
      # print p&lt;br /&gt;
&lt;br /&gt;
      f_elapsed = float(p[0])&lt;br /&gt;
&lt;br /&gt;
      t_elapsed = int(f_elapsed) + t_offset&lt;br /&gt;
&lt;br /&gt;
      if wallclockFlg == 1:&lt;br /&gt;
         t_wallclock = &amp;#039; &amp;#039;.join((p[1], p[2]))&lt;br /&gt;
      else:&lt;br /&gt;
         t_wallclock = &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
      location = p[3]&lt;br /&gt;
      task     = p[4]&lt;br /&gt;
&lt;br /&gt;
      if task == &amp;quot;BL_RequestSearch&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;value_request_id \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            request_id = tmatch.group(1)&lt;br /&gt;
            obj         = request_id&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      elif task == &amp;quot;BL_HomeRequestQueueWait&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;item \[(.*?)\] rq \[Value=(.*?)\] awb \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            item_no = tmatch.group(1)&lt;br /&gt;
            request_id = tmatch.group(2)&lt;br /&gt;
            awb_number = tmatch.group(3)&lt;br /&gt;
            obj        = &amp;quot;%s:%s&amp;quot; % (awb_number, request_id)&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      elif task == &amp;quot;BL_ActivityNew_No_Queue&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;new_activity_id \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            activity_id = tmatch.group(1)&lt;br /&gt;
            obj         = activity_id&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      elif task == &amp;quot;BL_ActivityEventCreate_No_Queue&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;item \[(.*?)\] match \[(.*?)\] value_task \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            item_no     = tmatch.group(1)&lt;br /&gt;
            activity_id = tmatch.group(2)&lt;br /&gt;
            value_task  = tmatch.group(3)&lt;br /&gt;
            obj         = activity_id&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;added to awb \[(.*?)\] value_activity_event \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            awb_number  = tmatch.group(1)&lt;br /&gt;
            event       = tmatch.group(2)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;Total Activities rows displayed \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            no_act      = tmatch.group(1)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;Total OpenActivities rows displayed \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            no_open_act = tmatch.group(1)&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      # added to awb [4288432503] request type [Value=task.event.arrangedPickupRecollection]&lt;br /&gt;
      elif task == &amp;quot;BL_RequestEventCreate_No_Queue&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;added to awb \[(.*?)\] request type \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            awb_number  = tmatch.group(1)&lt;br /&gt;
            req_type    = tmatch.group(2)&lt;br /&gt;
            obj         = awb_number&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      # new_sub_activity_id&lt;br /&gt;
      elif task == &amp;quot;BL_SubActivityNew_No_Queue&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;item \[(.*?)\] match \[(.*?)\] value_task \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            item_no     = tmatch.group(1)&lt;br /&gt;
            activity_id = tmatch.group(2)&lt;br /&gt;
            value_task  = tmatch.group(3)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;added to awb \[(.*?)\] value_activity_event \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            awb_number  = tmatch.group(1)&lt;br /&gt;
            event       = tmatch.group(2)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;Total Activities rows displayed \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            no_act      = tmatch.group(1)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;Total OpenActivities rows displayed \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            no_open_act = tmatch.group(1)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;new_sub_activity_id \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            sub_act_id  = tmatch.group(1)&lt;br /&gt;
            obj         = sub_act_id&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      elif task == &amp;quot;BL_ActivityClose_No_Queue&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;item \[(.*?)\] match \[(.*?)\] value_task \[Value=(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            item_no     = tmatch.group(1)&lt;br /&gt;
            activity_id = tmatch.group(2)&lt;br /&gt;
            value_task  = tmatch.group(3)&lt;br /&gt;
            obj         = activity_id&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;Total Activities rows displayed \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            no_act      = tmatch.group(1)&lt;br /&gt;
            continue&lt;br /&gt;
         tmatch = re.search(r&amp;#039;Total OpenActivities rows displayed \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            no_open_act = tmatch.group(1)&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
      elif task == &amp;quot;FL_AWBSearch&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;FL_AWBSearch_AdvancedSearch_NextStep&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            awb_number = &amp;quot;-&amp;quot;&lt;br /&gt;
            obj         = awb_number&lt;br /&gt;
         tmatch = re.search(r&amp;#039;AWB \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            awb_number  = tmatch.group(1)&lt;br /&gt;
            obj         = awb_number&lt;br /&gt;
            # print &amp;quot;AWB [%s]&amp;quot; % awb_number&lt;br /&gt;
            # continue&lt;br /&gt;
&lt;br /&gt;
      # FL_RequestCreate added to awb [4363566152] confirm / new_request_id [242991]&lt;br /&gt;
      elif task == &amp;quot;FL_RequestCreate&amp;quot;:&lt;br /&gt;
         tmatch = re.search(r&amp;#039;added to awb \[(.*?)\] confirm \/ new_request_id \[(.*?)\]&amp;#039;, p[5])&lt;br /&gt;
         if tmatch:&lt;br /&gt;
            awb_number  = tmatch.group(1)&lt;br /&gt;
            request_id  = tmatch.group(2)&lt;br /&gt;
            obj         = awb_number&lt;br /&gt;
&lt;br /&gt;
      if rewriteFlg:&lt;br /&gt;
         if endFlg == 1:&lt;br /&gt;
            endFlg = 0&lt;br /&gt;
            try:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s %s %s %s %s %s %s [%s] [%s]&amp;quot; % (hms(t_elapsed), p[1], p[2], vuser, p[3], p[4], p[5], username, obj)&lt;br /&gt;
            except:&lt;br /&gt;
               print &amp;quot;%s&amp;quot; % line&lt;br /&gt;
               sys.exit(0)&lt;br /&gt;
         else:&lt;br /&gt;
            print &amp;gt;&amp;gt;ofo, &amp;quot;%s %s %s %s %s %s %s&amp;quot; % (hms(t_elapsed), p[1], p[2], vuser, p[3], p[4], p[5])&lt;br /&gt;
      else:&lt;br /&gt;
         if ((task != current_task) or (re.search(r&amp;#039;global_current_action_name \[&amp;#039;, p[5]))):&lt;br /&gt;
            if current_task == &amp;quot;BL_RequestSearch&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     RequestID  %s&amp;quot; % (hms(t_elapsed), t_wallclock, vuser, current_task, request_id)&lt;br /&gt;
            elif current_task == &amp;quot;BL_HomeRequestQueueWait&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     RequestID  %s  AWB %s [%s]&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, request_id, awb_number, item_no)&lt;br /&gt;
            elif current_task == &amp;quot;BL_ActivityNew_No_Queue&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     ActivityID %s&amp;quot; % (hms(t_elapsed), t_wallclock, vuser, current_task, activity_id)&lt;br /&gt;
            elif current_task == &amp;quot;BL_ActivityEventCreate_No_Queue&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     ActivityID %s  AWB %s [%s:%s/%s]&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, activity_id, awb_number, item_no, no_open_act, no_act)&lt;br /&gt;
            elif current_task == &amp;quot;BL_RequestEventCreate_No_Queue&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     AWB %s  RequestType [%s]&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, awb_number, req_type)&lt;br /&gt;
            elif current_task == &amp;quot;BL_SubActivityNew_No_Queue&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     ActivityID %s  AWB %s [%s:%s/%s] SubActivityID %s&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, activity_id, awb_number, item_no, no_open_act, no_act, sub_act_id)&lt;br /&gt;
            elif current_task == &amp;quot;BL_ActivityClose_No_Queue&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     ActivityID  %s  [%s:%s/%s]&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, activity_id, item_no, no_open_act, no_act)&lt;br /&gt;
            elif current_task == &amp;quot;BL_RequestClose_No_Queue&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     RequestID   %s&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, request_id)&lt;br /&gt;
            elif current_task == &amp;quot;FL_AWBSearch&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     AWB %s&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, awb_number)&lt;br /&gt;
            elif current_task == &amp;quot;FL_RequestCreate&amp;quot;:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s     AWB %s  RequestID %s&amp;quot; % (hms(t_elapsed),&lt;br /&gt;
                  t_wallclock, vuser, current_task, awb_number, request_id)&lt;br /&gt;
            else:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;%s%s %s %-32s&amp;quot; % (hms(t_elapsed), t_wallclock, vuser, current_task)&lt;br /&gt;
&lt;br /&gt;
            if current_task and current_task.find(&amp;quot;EndIteration&amp;quot;) != -1:&lt;br /&gt;
               print &amp;gt;&amp;gt;ofo, &amp;quot;          -------------------------&amp;quot;&lt;br /&gt;
&lt;br /&gt;
         current_task = task&lt;br /&gt;
&lt;br /&gt;
   ifo.close()&lt;br /&gt;
   ofo.close()&lt;br /&gt;
&lt;br /&gt;
   print &amp;gt;&amp;gt;sys.stderr, &amp;quot;Processed %d lines&amp;quot; % cnt&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
   global filename&lt;br /&gt;
   global td_start&lt;br /&gt;
   global t_start&lt;br /&gt;
   global debugFlg&lt;br /&gt;
   global directoryFlg&lt;br /&gt;
   global stdoutFlg&lt;br /&gt;
   global verboseFlg&lt;br /&gt;
   global rewriteFlg&lt;br /&gt;
   global wallclockFlg&lt;br /&gt;
&lt;br /&gt;
   try:&lt;br /&gt;
      opts, args = getopt.getopt(sys.argv[1:], &amp;quot;dDf:ors:tvVw?&amp;quot;)&lt;br /&gt;
   except getopt.error, msg:&lt;br /&gt;
      print __doc__&lt;br /&gt;
      return 1&lt;br /&gt;
&lt;br /&gt;
   for o, a in opts:&lt;br /&gt;
      if o == &amp;#039;-d&amp;#039;:&lt;br /&gt;
         debugFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-D&amp;#039;:&lt;br /&gt;
         directoryFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-f&amp;#039;:&lt;br /&gt;
         filename = a&lt;br /&gt;
      elif o == &amp;#039;-o&amp;#039;:&lt;br /&gt;
         stdoutFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-s&amp;#039;:&lt;br /&gt;
         td_start = a&lt;br /&gt;
      elif o == &amp;#039;-v&amp;#039;:&lt;br /&gt;
         verboseFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-V&amp;#039;:&lt;br /&gt;
         print &amp;quot;Version: %s&amp;quot; % __version__&lt;br /&gt;
         return 1&lt;br /&gt;
      elif o == &amp;#039;-r&amp;#039;:&lt;br /&gt;
         rewriteFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-t&amp;#039;:&lt;br /&gt;
         rewriteFlg = 1&lt;br /&gt;
         wallclockFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-w&amp;#039;:&lt;br /&gt;
         wallclockFlg = 1&lt;br /&gt;
      elif o == &amp;#039;-?&amp;#039;:&lt;br /&gt;
         print __doc__&lt;br /&gt;
         return 1&lt;br /&gt;
&lt;br /&gt;
   if (debugFlg):&lt;br /&gt;
      print &amp;quot;&amp;gt;&amp;gt; Flg    %s&amp;quot; % debugFlg&lt;br /&gt;
&lt;br /&gt;
   if td_start:&lt;br /&gt;
      t_start          = startSeconds(td_start)&lt;br /&gt;
      print &amp;quot;Start     = %d&amp;quot; % t_start&lt;br /&gt;
   else:&lt;br /&gt;
      t_start          = None&lt;br /&gt;
&lt;br /&gt;
   if directoryFlg:&lt;br /&gt;
      files = glob.glob(&amp;quot;*.log&amp;quot;)&lt;br /&gt;
      for file in files:&lt;br /&gt;
         parse(file)&lt;br /&gt;
   elif args:&lt;br /&gt;
      for arg in args:&lt;br /&gt;
         parse(arg)&lt;br /&gt;
   else:&lt;br /&gt;
      parse(filename)&lt;br /&gt;
&lt;br /&gt;
   if rewriteFlg:&lt;br /&gt;
      print &amp;quot;Concatenating rewritten output files&amp;quot;&lt;br /&gt;
      os.system(&amp;#039;cat *.out &amp;gt; logs.rewriten&amp;#039;)&lt;br /&gt;
      print &amp;quot;Sorting rewritten logs&amp;quot;&lt;br /&gt;
      os.system(&amp;#039;sort logs.rewriten &amp;gt; logs.sorted&amp;#039;)&lt;br /&gt;
      os.system(&amp;#039;rm -f logs.rewriten&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
      # Pickle the vuser/node mapping&lt;br /&gt;
&lt;br /&gt;
      print str(node_map)&lt;br /&gt;
      f = open(&amp;#039;node_map.dump&amp;#039;, &amp;#039;w&amp;#039;)&lt;br /&gt;
      pickle.dump(node_map, f)&lt;br /&gt;
      f.close()&lt;br /&gt;
&lt;br /&gt;
   return 1&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;#039;__main__&amp;#039; or __name__ == sys.argv[0]:&lt;br /&gt;
   sys.exit(main())&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Revision History:&lt;br /&gt;
&lt;br /&gt;
     Date     Who   Description&lt;br /&gt;
   --------   ---   --------------------------------------------------&lt;br /&gt;
   20040603   plh   Initial implementation&lt;br /&gt;
&lt;br /&gt;
Problems to fix:&lt;br /&gt;
&lt;br /&gt;
To Do:&lt;br /&gt;
&lt;br /&gt;
Issues:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
0000.0 [2004-06-11 20:55:34] ../lib/Utils.c:775 BL_Login Timestamp (1086951334) - Fri Jun 11 20:55:34 2004&lt;br /&gt;
&lt;br /&gt;
0000.0 [2004-06-11 20:55:34] ../lib/Login.c:42 BL_Login Login - (VUser Backline:68)&lt;br /&gt;
0000.0 [2004-06-11 20:55:34] ../lib/Login.c:45 BL_Login host [node1.perf:7001] username [BbMELGTW] password [BbMELGTW]&lt;br /&gt;
0000.0 [2004-06-11 20:55:34] ../lib/Utils.c:1179 BL_Login start transaction [BL_Login_Home]&lt;br /&gt;
0002.0 [2004-06-11 20:55:36] ../lib/Utils.c:1101 BL_Login end transaction [BL_Login_Home]&lt;br /&gt;
0002.0 [2004-06-11 20:55:36] ../lib/Utils.c:1107 BL_Login transaction duration [BL_Login_Home] [2.273965]&lt;br /&gt;
0014.0 [2004-06-11 20:55:48] ../lib/Utils.c:1179 BL_Login start transaction [BL_Login_Redirect]&lt;br /&gt;
0016.0 [2004-06-11 20:55:50] ../lib/Utils.c:1101 BL_Login end transaction [BL_Login_Redirect]&lt;br /&gt;
0016.0 [2004-06-11 20:55:50] ../lib/Utils.c:1107 BL_Login transaction duration [BL_Login_Redirect] [0.218618]&lt;br /&gt;
0024.0 [2004-06-11 20:55:58] ../lib/Utils.c:1194 BL_Login start transaction [BL_Login_NotificationInitFrame]&lt;br /&gt;
0026.0 [2004-06-11 20:56:00] ../lib/Utils.c:1101 BL_Login end transaction [BL_Login_NotificationInitFrame]&lt;br /&gt;
0026.0 [2004-06-11 20:56:00] ../lib/Utils.c:1107 BL_Login transaction duration [BL_Login_NotificationInitFrame] [0.003013]&lt;br /&gt;
0037.0 [2004-06-11 20:56:11] ../lib/Utils.c:1179 BL_Login start transaction [BL_Login_Send]&lt;br /&gt;
0039.0 [2004-06-11 20:56:13] ../lib/Utils.c:1101 BL_Login end transaction [BL_Login_Send]&lt;br /&gt;
0039.0 [2004-06-11 20:56:13] ../lib/Utils.c:1107 BL_Login transaction duration [BL_Login_Send] [1.581912]&lt;br /&gt;
0047.0 [2004-06-11 20:56:21] ../lib/NotificationInit.c:6 BL_NotificationInit global_current_action_name [NotificationInit]&lt;br /&gt;
0047.0 [2004-06-11 20:56:21] ../lib/Utils.c:1588 BL_NotificationInit BL_NotificationInit&lt;br /&gt;
0047.0 [2004-06-11 20:56:21] ../lib/Utils.c:1194 BL_NotificationInit start transaction [BL_NotificationInit_InitFrame]&lt;br /&gt;
0049.0 [2004-06-11 20:56:23] ../lib/Utils.c:1101 BL_NotificationInit end transaction [BL_NotificationInit_InitFrame]&lt;br /&gt;
0049.0 [2004-06-11 20:56:23] ../lib/Utils.c:1107 BL_NotificationInit transaction duration [BL_NotificationInit_InitFrame] [0.061407]&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/StartIteration.c:5 BL_StartIteration global_current_action_name [StartIteration]&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/Utils.c:1588 BL_StartIteration BL_StartIteration&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/StartIteration.c:8 BL_StartIteration start user data point [BL_IterationTransaction]&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/NotificationRender.c:12 BL_NotificationRender global_current_action_name [NotificationRender]&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/Utils.c:1588 BL_NotificationRender BL_NotificationRender&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/NotificationRender.c:18 BL_NotificationRender notification_interval [13.000000].&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] BL_HomeRequestQueueWait.c:15 BL_HomeRequestQueueWait global_current_action_name [HomeRequestQueueWait]&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/Utils.c:1588 BL_HomeRequestQueueWait BL_HomeRequestQueueWait&lt;br /&gt;
0060.0 [2004-06-11 20:56:34] ../lib/Utils.c:1179 BL_HomeRequestQueueWait start transaction [BL_HomeRequestQueueWait_Home]&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Python]]&lt;br /&gt;
[[Category:Log Analysis]]&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>