Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^14: Log Parsing

by poj (Abbot)
on May 11, 2017 at 13:37 UTC ( [id://1190060]=note: print w/replies, xml ) Need Help??


in reply to Re^13: Log Parsing
in thread Log Parsing

Ok try

#!/usr/bin/perl use strict; my $reqid = '8274'; my $infile = 'worker.log'; open IN,'<',$infile or die "$!"; # input my %data = (); my @id = (); 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; } while ( /\{(\d+)-SUCCESSFUL\}/g ){ push @id,$1 if ($taskid eq $reqid); } } close IN; # output print join ',',('Task id','Start time',"End time\n"); for my $id (sort @id){ if (exists $data{$id}){ for my $proc (reverse sort keys %{$data{$id}}){ printf "%s,%s,%s\n","$id $proc",@{$data{$id}{$proc}}; } } else { print OUT "$id- no data\n"; } }
poj

Replies are listed 'Best First'.
Re^15: Log Parsing
by piyushmnnit06 (Novice) on May 12, 2017 at 10:54 UTC

    thanks it is working fine

      one more help is needed the timings which are coming in results contains extra digits something like this 10:04:56.499+0000 but I want only till seconds 10:04:56

      reason being is that I am not able to subtract these timings so I want processing time =endtime-start time for every task id

      Could you please help regarding that, can we subtract them in the same program

        Firstly you've replied to yourself, secondly please make an effort to solve this yourself, and post any actual problems you have, rather than another requirement you have to deliver.

Re^15: Log Parsing
by piyushmnnit06 (Novice) on May 16, 2017 at 07:09 UTC

    for proper time format I have made changes and it is working fine , I used $timestamp= substr $timestamp, 0, 8;

    but I am not able to find out how to get the subtraction End time and Start time in the same program

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1190060]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found