in reply to Re^9: Log Parsing
in thread Log Parsing
Try
poj#!/usr/bin/perl use strict; my $infile = 'worker.log'; open IN,'<',$infile or die "$!"; # input my %data = (); while (<IN>) { chomp; next unless /Task:id=(\d+)/; my $taskid = $1; my (undef,$timestamp,undef) = split /\s+/,$_,3; if (/(Started|Submitted|Done).*(consuming|job)/){ my $i = ($1 eq 'Done') ? 1 : 0; my $proc = ($2 eq 'consuming') ? $2 : 'Submitted'; $data{$taskid.' '.$proc}[$i] = $timestamp; } } close IN; # output print join ',',('Task id','Start time',"End time\n"); for my $id (reverse sort keys %data){ printf "%s,%s,%s\n",$id,@{$data{$id}}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Log Parsing
by piyushmnnit06 (Novice) on May 11, 2017 at 07:54 UTC | |
by poj (Abbot) on May 11, 2017 at 09:01 UTC | |
by piyushmnnit06 (Novice) on May 11, 2017 at 12:49 UTC | |
by poj (Abbot) on May 11, 2017 at 13:37 UTC | |
by piyushmnnit06 (Novice) on May 12, 2017 at 10:54 UTC | |
| |
by piyushmnnit06 (Novice) on May 16, 2017 at 07:09 UTC |