(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           ## the sort process and maps the time from the format seconds and microseconds
 7           ## to a decimal number of fixed length for the subsequent sort.
 8           
 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           ## This script substitutes for the EOL character in those lines where
15           ## the EOL does not represent a complete record for the input files and
16           ## outputs the result to a temp output file the substitution is defined in
17           ## localRS below
18           
19           ## Consolidate the current line and the record accumulator if it exists
20           ## and output the result to the std ouput
21           BEGIN {
22 karl  1.1     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           ## This line is not a complete log record.  Time field not correct
32           ## 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           ## for all trace records (i.e. with time), accumulate everything until the next
40           ## 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 karl  1.1 ## 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               {
62                   print accum
63                   accum = ""
64 karl  1.1     }
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               #### print "" > namesFile
79               cmd="rm -f " namesFile
80               system(cmd) 
81               for (id in filenameArray)
82               {
83                   print  item, filenameArray[id] >> namesFile
84               }
85 karl  1.1 }
86           
87           

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2