(file) Return to consolidateTrace.awk CVS log (file) (dir) Up to [Pegasus] / pegasus_unsupported / scripts / formattrace

 1 karl  1.1 ##
 2           ## This awk script consolidates multiple OpenPegasus log files from
 3           ## the various OOP processes (Each process generates a separate log file)
 4           ## into a single log file sorted by time.  
 5           ## It consolidates multiple line log records into single line records for
 6 karl  1.2 ## the sort process and maps the time from the original trace format
 7           ## for subsequent sort.
 8 karl  1.1 
 9           ## It produces an output of the records from all input trace files consolidated
10           ## into a single output stream to standard output
11           
12           ## awk -f consolidateTrace.awk [input file list] >outputfile
13           
14 karl  1.2 ## 
15 karl  1.1 ## This script substitutes for the EOL character in those lines where
16           ## the EOL does not represent a complete record for the input files and
17           ## outputs the result to a temp output file the substitution is defined in
18 karl  1.2 ## localRS below. This is to ensure that multiline trace elements (ex.
19           ## the XML output) gets sorted as a single entity.
20 karl  1.1 
21           BEGIN {
22               accum = ""
23               ## local record separator.  NOTE: This may be to simplistic since we
24               ## are just using a single character (formfeed) as the separator right
25               ## now. We could consider a more complex pattern but then would have
26               ## to modify also the script that reseparates this into multiple lines.
27               LocalRS = "\f"
28               namesFile = "FileNames.txt"
29           }
30           
31 karl  1.2 ## This line is not a complete log record, time field not correct
32 karl  1.1 ## add the current record to the record accumulator with the localRS
33           ## (Record Separator) since this is  a multiline log record (i.e. no time as
34           ## first field)
35           $0 !~ /^[0-9]{10}s-[0-9]{1,6}us: / {
36               accum = accum LocalRS $0
37           }
38           
39 karl  1.2 ## For all trace records (i.e. with time), accumulate everything until the next
40 karl  1.1 ## trace record in an accumulator record. Also map to a fixed length output
41           ## for the time field so that it sorts properly.  This is because the
42           ## microseconds part today is variable length (i.e. number of microseconds
43           ## as opposed to parts of a second so that the field length is variable
44           
45           /^[0-9]{10}s-[0-9]{1,6}us: / {
46               ## Normalize the time field for a sort from  seconds and microseconds
47               ## seconds.microseconds as a single decimal number of fixed length so 
48               ## we can use the sort program correctly.
49               split($1, timeFields,"-")
50               sub("s$","",timeFields[1])
51               sub("us:$","",timeFields[2])
52           
53               ## expand the us field to 6 characters.
54               while (length(timeFields[2]) < 6)
55               {
56                   timeFields[2] = "0" timeFields[2]
57               }
58               $1 = timeFields[1] "." timeFields[2] ":"
59           
60               if (accum != "")
61 karl  1.1     {
62                   print accum
63                   accum = ""
64               }
65               accum = $0
66           }
67           
68           ## get the filename if this is the first record of a file
69           ## Assumes the first record is a valid log record.
70           FNR == 1{
71               ## get the process id and save the file name for that process ID
72               processID = substr($3,2,4)
73               filenameArray[processID] = FILENAME
74           }
75           
76           ## output the array of process IDs vs filenames into a file for later use.
77           END {
78               for (id in filenameArray)
79               {
80 karl  1.2         print  id, filenameArray[id] >> namesFile
81 karl  1.1     }
82           }
83           
84           

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2