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

File: [Pegasus] / pegasus_unsupported / scripts / formattrace / consolidateTrace.awk (download)
Revision: 1.2, Sat Nov 8 19:41:03 2014 UTC (9 years, 7 months ago) by karl
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +8 -11 lines
BUG#:9999
TITLE: Add scripts for chotesting and update the formattrace scripts

DESCRIPTION: These are unsupported test extensions for use in pegasus
development and testing.  Each has help and readme files.

##
## This awk script consolidates multiple OpenPegasus log files from
## the various OOP processes (Each process generates a separate log file)
## into a single log file sorted by time.  
## It consolidates multiple line log records into single line records for
## the sort process and maps the time from the original trace format
## for subsequent sort.

## It produces an output of the records from all input trace files consolidated
## into a single output stream to standard output

## awk -f consolidateTrace.awk [input file list] >outputfile

## 
## This script substitutes for the EOL character in those lines where
## the EOL does not represent a complete record for the input files and
## outputs the result to a temp output file the substitution is defined in
## localRS below. This is to ensure that multiline trace elements (ex.
## the XML output) gets sorted as a single entity.

BEGIN {
    accum = ""
    ## local record separator.  NOTE: This may be to simplistic since we
    ## are just using a single character (formfeed) as the separator right
    ## now. We could consider a more complex pattern but then would have
    ## to modify also the script that reseparates this into multiple lines.
    LocalRS = "\f"
    namesFile = "FileNames.txt"
}

## This line is not a complete log record, time field not correct
## add the current record to the record accumulator with the localRS
## (Record Separator) since this is  a multiline log record (i.e. no time as
## first field)
$0 !~ /^[0-9]{10}s-[0-9]{1,6}us: / {
    accum = accum LocalRS $0
}

## For all trace records (i.e. with time), accumulate everything until the next
## trace record in an accumulator record. Also map to a fixed length output
## for the time field so that it sorts properly.  This is because the
## microseconds part today is variable length (i.e. number of microseconds
## as opposed to parts of a second so that the field length is variable

/^[0-9]{10}s-[0-9]{1,6}us: / {
    ## Normalize the time field for a sort from  seconds and microseconds
    ## seconds.microseconds as a single decimal number of fixed length so 
    ## we can use the sort program correctly.
    split($1, timeFields,"-")
    sub("s$","",timeFields[1])
    sub("us:$","",timeFields[2])

    ## expand the us field to 6 characters.
    while (length(timeFields[2]) < 6)
    {
        timeFields[2] = "0" timeFields[2]
    }
    $1 = timeFields[1] "." timeFields[2] ":"

    if (accum != "")
    {
        print accum
        accum = ""
    }
    accum = $0
}

## get the filename if this is the first record of a file
## Assumes the first record is a valid log record.
FNR == 1{
    ## get the process id and save the file name for that process ID
    processID = substr($3,2,4)
    filenameArray[processID] = FILENAME
}

## output the array of process IDs vs filenames into a file for later use.
END {
    for (id in filenameArray)
    {
        print  id, filenameArray[id] >> namesFile
    }
}



No CVS admin address has been configured
Powered by
ViewCVS 0.9.2