(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.1, Thu Mar 20 14:11:24 2014 UTC (10 years, 3 months ago) by karl
Branch: MAIN
PEP#: 000
TITLE: Add utility script to format OpenPegasus trace files.

DESCRIPTION: This adds a set of bash/awk scripts to format the trace
files for OpenPegasus into a more readable form. There is a readme
included that defines how to use this utility.  This is primarily
a developer utility today and this is a first prototype.

##
## 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 format seconds and microseconds
## to a decimal number of fixed length for the 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

## Consolidate the current line and the record accumulator if it exists
## and output the result to the std ouput
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 {
    #### print "" > namesFile
    cmd="rm -f " namesFile
    system(cmd) 
    for (id in filenameArray)
    {
        print  item, filenameArray[id] >> namesFile
    }
}



No CVS admin address has been configured
Powered by
ViewCVS 0.9.2