Skip to content
Snippets Groups Projects
Commit e29e7d53 authored by Oliver Breitwieser's avatar Oliver Breitwieser
Browse files

Add quick awk script to parse jenkins log

Change-Id: Ic49ddb2b2200339984252266e58508de90660f0c
parent 09f4bc88
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/awk -f
# Parses timestamp and counts seconds
# Only prints commands that took longer than a second.
function date_to_sec(date)
{
if ( ! ( date ~ /\[[\-0-9]*T[:.0-9]*Z\]/ ) )
{
return "FAIL"
}
# clear brackets from date
gsub(/(\[|\])/, "", date)
date = sprintf("(date +%%s.%%N -d '%s' || echo FAIL) 2>/dev/null", date)
date | getline secs
close(date)
return secs
}
{
secs = date_to_sec($1)
if (secs != "FAIL")
{
elapsed = secs - last
last = secs
if (elapsed > 0)
{
if ( ! (last_command ~ /^$/ ))
{
# the elapsed time is for the PREVIOUS line of input
print elapsed last_command
}
}
$1 = ""
last_command = $0
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment