line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Milter::Authentication::Handler::Size; |
2
|
1
|
|
|
1
|
|
836
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use base 'Mail::Milter::Authentication::Handler'; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
86
|
|
5
|
|
|
|
|
|
|
our $VERSION = '20191206'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use Data::Dumper; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
83
|
|
8
|
1
|
|
|
1
|
|
7
|
use English qw{ -no_match_vars }; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
22
|
|
9
|
1
|
|
|
1
|
|
640
|
use Sys::Syslog qw{:standard :macros}; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
511
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub default_config { |
12
|
0
|
|
|
0
|
0
|
|
return {}; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub grafana_rows { |
16
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
17
|
0
|
|
|
|
|
|
my @rows; |
18
|
0
|
|
|
|
|
|
push @rows, $self->get_json( 'Size_metrics' ); |
19
|
0
|
|
|
|
|
|
return \@rows; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub register_metrics { |
23
|
|
|
|
|
|
|
return { |
24
|
0
|
|
|
0
|
1
|
|
'size_total' => 'The number of emails processed for Size', |
25
|
|
|
|
|
|
|
'size_header_bytes_total' => 'The header size of emails processed for Size', |
26
|
|
|
|
|
|
|
'size_body_bytes_total' => 'The body size of emails processed for Size', |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub envfrom_callback { |
31
|
0
|
|
|
0
|
0
|
|
my ( $self, $env_from ) = @_; |
32
|
0
|
|
|
|
|
|
$self->{'headersize'} = 0; |
33
|
0
|
|
|
|
|
|
$self->{'bodysize'} = 0; |
34
|
0
|
|
|
|
|
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub header_callback { |
38
|
0
|
|
|
0
|
0
|
|
my ( $self, $header, $value ) = @_; |
39
|
0
|
|
|
|
|
|
$self->{ 'headersize' } = $self->{ 'headersize' } + length( $header . ': ' . $value ) + 2; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub body_callback { |
45
|
0
|
|
|
0
|
0
|
|
my ( $self, $body_chunk ) = @_; |
46
|
0
|
|
|
|
|
|
$self->{ 'bodysize' } = $self->{ 'bodysize' } + length ( $body_chunk ); |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub eom_callback { |
51
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->metric_count( 'size_total', {}, 1 ); |
54
|
0
|
|
|
|
|
|
$self->metric_count( 'size_header_bytes_total', {}, $self->{ 'headersize' } ); |
55
|
0
|
|
|
|
|
|
$self->metric_count( 'size_body_bytes_total', {}, $self->{ 'bodysize' } ); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub close_callback { |
61
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
62
|
0
|
|
|
|
|
|
delete $self->{'bodysize'}; |
63
|
0
|
|
|
|
|
|
delete $self->{'headersize'}; |
64
|
0
|
|
|
|
|
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding UTF-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Mail::Milter::Authentication::Handler::Size |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 20191206 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Module to provide metrics related to message size. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 CONFIGURATION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
"Size" : {}, | Config for the Size Module |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Marc Bradshaw. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |