line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::QmailSend::MultilogParser; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
67828
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
87
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1757
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
21
|
my ($class, %args) = @_; |
10
|
1
|
|
|
|
|
6
|
my $self = { callback => undef, %args }; |
11
|
1
|
|
|
|
|
13
|
bless $self, $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse { |
15
|
1
|
|
|
1
|
0
|
59
|
my ($self, $fh) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
2
|
my(%msg, %dline, $inode, $delnum); |
18
|
1
|
|
|
|
|
63
|
while (<$fh>) { |
19
|
500
|
|
|
|
|
580
|
chomp; |
20
|
500
|
100
|
|
|
|
3225
|
if (m/([^ ]+( [^ ]+)?) new msg (\d+)/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
21
|
71
|
|
|
|
|
125
|
$inode = $3; |
22
|
71
|
|
|
|
|
242
|
$msg{$inode}{time_new} = $1; |
23
|
71
|
|
|
|
|
79
|
push @{$msg{$inode}{logs}}, $_; |
|
71
|
|
|
|
|
686
|
|
24
|
|
|
|
|
|
|
} elsif (m/[^ ]+ info msg (\d+): bytes \d+ from <([^>]+)?> qp \d+ uid \d+/) { |
25
|
71
|
|
|
|
|
119
|
$inode = $1; |
26
|
71
|
|
|
|
|
162
|
$msg{$inode}{from} = $2; |
27
|
71
|
|
|
|
|
80
|
push @{$msg{$inode}{logs}}, $_; |
|
71
|
|
|
|
|
611
|
|
28
|
|
|
|
|
|
|
} elsif (m/[^ ]+ starting delivery (\d+): msg (\d+) to (remote|local) ([^ ]+)/) { |
29
|
71
|
|
|
|
|
121
|
$inode = $2; |
30
|
71
|
|
|
|
|
94
|
$delnum = $1; |
31
|
71
|
|
|
|
|
188
|
$dline{$delnum} = $2; |
32
|
71
|
|
|
|
|
149
|
$msg{$inode}{msgnum} = $2; |
33
|
71
|
|
|
|
|
243
|
$msg{$inode}{delivery}{$delnum}{delnum} = $delnum; |
34
|
71
|
|
|
|
|
192
|
$msg{$inode}{delivery}{$delnum}{tochan} = $3; |
35
|
71
|
|
|
|
|
177
|
$msg{$inode}{delivery}{$delnum}{rcpt} = $4; |
36
|
71
|
|
|
|
|
66
|
push @{$msg{$inode}{logs}}, $_; |
|
71
|
|
|
|
|
872
|
|
37
|
|
|
|
|
|
|
} elsif (m/([^ ]+( [^ ]+)?) delivery (\d+): ([^:]+): (.+)/) { |
38
|
72
|
100
|
66
|
|
|
390
|
if (exists $dline{$3} && length $dline{$3}) { |
39
|
71
|
|
|
|
|
106
|
$delnum = $3; |
40
|
71
|
|
|
|
|
103
|
$inode = $dline{$delnum}; |
41
|
71
|
|
|
|
|
211
|
$msg{$inode}{delivery}{$delnum}{action} = $4; |
42
|
71
|
|
|
|
|
163
|
$msg{$inode}{delivery}{$delnum}{reason} = $5; |
43
|
71
|
|
|
|
|
73
|
push @{$msg{$inode}{logs}}, $_; |
|
71
|
|
|
|
|
141
|
|
44
|
71
|
|
|
|
|
662
|
delete $dline{$delnum}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} elsif (m/([^ ]+( [^ ]+)?) end msg (\d+)/) { |
47
|
72
|
|
|
|
|
113
|
$inode = $3; |
48
|
72
|
|
|
|
|
73
|
push @{$msg{$inode}{logs}}, $_; |
|
72
|
|
|
|
|
174
|
|
49
|
72
|
100
|
|
|
|
187
|
unless (exists $msg{$inode}{time_new}) { |
50
|
1
|
|
|
|
|
4
|
delete $msg{$inode}; |
51
|
1
|
|
|
|
|
8
|
next; |
52
|
|
|
|
|
|
|
} |
53
|
71
|
|
|
|
|
179
|
$msg{$inode}{time_end} = $1; |
54
|
71
|
|
|
|
|
478
|
my $data = { |
55
|
|
|
|
|
|
|
msgnum => $msg{$inode}{msgnum}, |
56
|
|
|
|
|
|
|
time_new => $msg{$inode}{time_new}, |
57
|
|
|
|
|
|
|
time_end => $msg{$inode}{time_end}, |
58
|
|
|
|
|
|
|
from => $msg{$inode}{from} || '(null)', |
59
|
71
|
|
50
|
|
|
244
|
delivery => [ map { $msg{$inode}{delivery}{$_} } keys %{$msg{$inode}{delivery}} ], |
|
71
|
|
|
|
|
360
|
|
60
|
|
|
|
|
|
|
logs => $msg{$inode}{logs}, |
61
|
|
|
|
|
|
|
}; |
62
|
71
|
50
|
|
|
|
305
|
$self->{callback}->($data) if defined $self->{callback}; |
63
|
71
|
|
|
|
|
926
|
delete $msg{$inode}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |