1
|
#!/usr/bin/perl -w
|
2
|
|
3
|
use strict;
|
4
|
use warnings;
|
5
|
|
6
|
my $filename = shift;
|
7
|
|
8
|
open(my $fh, '<:encoding(UTF-8)', $filename)
|
9
|
or die "Could not open file '$filename' $!";
|
10
|
|
11
|
my @request_entries;
|
12
|
my $is_request_entry = 0;
|
13
|
|
14
|
while (my $row = <$fh>) {
|
15
|
chomp $row;
|
16
|
|
17
|
if ($row =~ m/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d (\d+) \[(\d+)\] Request: \*+/) {
|
18
|
my $pid1 = $1;
|
19
|
my $pid2 = $2;
|
20
|
push @request_entries, { pid1 => $pid1, pid2 => $pid2, request => '', routing => '', time => -1 };
|
21
|
$is_request_entry = 1;
|
22
|
|
23
|
} elsif ($row =~ m/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d (\d+) \[(\d+)\] time: (\d+.\d+)/) {
|
24
|
my $pid1 = $1;
|
25
|
my $pid2 = $2;
|
26
|
my $time = $3;
|
27
|
|
28
|
$is_request_entry = 0;
|
29
|
|
30
|
my $found = -1;
|
31
|
foreach my $i (reverse 0..$#request_entries) {
|
32
|
if ($request_entries[$i]->{pid1} == $pid1 && $request_entries[$i]->{pid2} == $pid2) {
|
33
|
$found = $i;
|
34
|
last;
|
35
|
}
|
36
|
}
|
37
|
if ($found != -1) {
|
38
|
$request_entries[$found]->{time} = $time;
|
39
|
}
|
40
|
|
41
|
} elsif ($row =~ m/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d (\d+) \[(\d+)\]/) {
|
42
|
$is_request_entry = 0;
|
43
|
|
44
|
} elsif (!!$is_request_entry) {
|
45
|
$request_entries[-1]->{request} = $row if $is_request_entry == 1;
|
46
|
$request_entries[-1]->{routing} = $row if $is_request_entry == 2;
|
47
|
$request_entries[-1]->{params} .= $row . "\n" if $is_request_entry > 4; # 3 is empty, 4 is word "Params"
|
48
|
$is_request_entry++;
|
49
|
|
50
|
} else {
|
51
|
print "unknown line: $row\n";
|
52
|
}
|
53
|
}
|
54
|
|
55
|
# sort by timne
|
56
|
@request_entries = sort { $a->{time} <=> $b->{time} } @request_entries;
|
57
|
|
58
|
foreach my $r (@request_entries) {
|
59
|
if ($r->{routing} =~ m/action: add_item/) {
|
60
|
#print $r->{request} . "\n";
|
61
|
#print $r->{routing} . "\n";
|
62
|
print $r->{time} . "\n";
|
63
|
#print $r->{params} . "\n";
|
64
|
#print "\n";
|
65
|
}
|
66
|
}
|
67
|
|