| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::Saftpresse::Plugin::Postfix::Smtpd; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1637
|
use Moose::Role; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: plugin to gather postfix/smtpd advanced statistics |
|
6
|
|
|
|
|
|
|
our $VERSION = '1.6'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5282
|
use Log::Saftpresse::Plugin::Postfix::Utils qw( gimme_domain ); |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
82
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use Time::Piece; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
11
|
1
|
|
|
1
|
|
71
|
use Time::Seconds; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
493
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub process_smtpd { |
|
14
|
0
|
|
|
0
|
0
|
|
my ( $self, $stash, $notes ) = @_; |
|
15
|
0
|
|
|
|
|
|
my $service = $stash->{'service'}; |
|
16
|
0
|
|
|
|
|
|
my $message = $stash->{'message'}; |
|
17
|
0
|
|
|
|
|
|
my $qid = $stash->{'queue_id'}; |
|
18
|
0
|
|
|
|
|
|
my $pid = $stash->{'pid'}; |
|
19
|
0
|
|
|
|
|
|
my $time = $stash->{'time'}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
0
|
0
|
|
|
|
if( $service eq 'pickup' && $message =~ /^(sender|uid)=/) { |
|
22
|
0
|
|
|
|
|
|
$notes->set( 'client-'.$qid => 'pickup' ); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if( $service ne 'smtpd' ) { return; } |
|
|
0
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
0
|
0
|
|
|
|
if( defined $qid && $message =~ /client=(.+?)(,|$)/ ) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$notes->set( 'client-'.$qid => gimme_domain($1) ); |
|
29
|
|
|
|
|
|
|
} elsif ( defined $pid && $message =~ /^connect from / ) { |
|
30
|
0
|
|
|
|
|
|
$notes->set( 'pid-connect-'.$pid => $time ); |
|
31
|
0
|
|
|
|
|
|
$self->new_tracking_id($stash, $notes); |
|
32
|
|
|
|
|
|
|
} elsif ( defined $pid && |
|
33
|
|
|
|
|
|
|
( my ($host) = $message =~ /^disconnect from (.+)$/) ) { |
|
34
|
0
|
|
|
|
|
|
my $host = gimme_domain($host); |
|
35
|
0
|
|
|
|
|
|
my $conn_time = $notes->get( 'pid-connect-'.$pid ); |
|
36
|
0
|
0
|
|
|
|
|
if( ! defined $conn_time ) { return; } |
|
|
0
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $elapsed = $time - $conn_time; |
|
38
|
0
|
|
|
|
|
|
my $sec = $elapsed->seconds; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$stash->{'connection_time'} = $sec; |
|
41
|
0
|
|
|
|
|
|
$stash->{'client'} = $host; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if( $self->saftsumm_mode ) { |
|
44
|
0
|
|
|
|
|
|
$self->incr_host_one( $stash, 'conn', 'per_hr', $time->hour); |
|
45
|
0
|
|
|
|
|
|
$self->incr_host_one( $stash, 'conn', 'per_day', $time->ymd); |
|
46
|
0
|
|
|
|
|
|
$self->incr_host( $stash, 'conn', 'busy', 'per_hr', $time->hour, $sec); |
|
47
|
0
|
|
|
|
|
|
$self->incr_host( $stash, 'conn', 'busy', 'per_day', $time->ymd, $sec); |
|
48
|
0
|
|
|
|
|
|
$self->incr_host_max( $stash, 'conn', 'busy', 'max_per_hr', $time->hour, $sec); |
|
49
|
0
|
|
|
|
|
|
$self->incr_host_max( $stash, 'conn', 'busy', 'max_per_day', $time->ymd, $sec); |
|
50
|
0
|
|
|
|
|
|
$self->incr_host_max( $stash, 'conn', 'busy', 'max_per_domain', $host, $sec); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
0
|
|
|
|
|
|
$self->incr_host_one( $stash, 'conn', 'per_domain', $host); |
|
53
|
0
|
|
|
|
|
|
$self->incr_host( $stash, 'conn', 'busy', 'per_domain', $host, $sec); |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$self->incr_host_one( $stash, 'conn', 'total'); |
|
56
|
0
|
|
|
|
|
|
$self->incr_host( $stash, 'conn', 'busy', 'total', $sec); |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$self->clear_tracking_id('pid', $stash, $notes); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Log::Saftpresse::Plugin::Postfix::Smtpd - plugin to gather postfix/smtpd advanced statistics |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 1.6 |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is free software, licensed under: |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |