line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: a fast and reliable mailq-like utility for postfix |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Postfix::Mailq; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
51282
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
76
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
735
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub DEFAULT_SPOOL_DIR () { '/var/spool/postfix' } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_fast_count { |
12
|
2
|
|
|
2
|
1
|
1741
|
my ($opt) = @_; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
50
|
|
|
7
|
$opt ||= {}; |
15
|
|
|
|
|
|
|
|
16
|
2
|
100
|
|
|
|
8
|
my $get_hold = $opt->{get_hold} ? 1 : 0; |
17
|
2
|
50
|
33
|
|
|
16
|
my $spool_dir = defined $opt->{spool_dir} && $opt->{spool_dir} ne '' |
18
|
|
|
|
|
|
|
? $opt->{spool_dir} |
19
|
|
|
|
|
|
|
: DEFAULT_SPOOL_DIR; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
11
|
my %count = ( |
22
|
|
|
|
|
|
|
total => 0, |
23
|
|
|
|
|
|
|
active => 0, |
24
|
|
|
|
|
|
|
incoming => 0, |
25
|
|
|
|
|
|
|
deferred => 0, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
8
|
my @dirs = ('active', 'incoming', map { "deferred/$_" } 0..9, 'A'..'F'); |
|
32
|
|
|
|
|
88
|
|
29
|
2
|
100
|
|
|
|
11
|
push @dirs, 'hold' if $get_hold; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
4
|
for my $dir (@dirs) { |
32
|
|
|
|
|
|
|
|
33
|
37
|
100
|
|
|
|
856
|
opendir(my $dh, "$spool_dir/$dir") || next; |
34
|
|
|
|
|
|
|
|
35
|
5
|
|
|
|
|
7
|
my $n = 0; |
36
|
5
|
|
|
|
|
49
|
while (my $item = readdir($dh)) { |
37
|
21
|
100
|
|
|
|
108
|
++$n unless $item =~ m{^\.}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
|
|
7
|
$count{total} += $n; |
41
|
|
|
|
|
|
|
|
42
|
5
|
50
|
|
|
|
12
|
if ($dir =~ m{^deferred}) { |
43
|
0
|
|
|
|
|
0
|
$count{deferred} += $n; |
44
|
|
|
|
|
|
|
} else { |
45
|
5
|
|
|
|
|
75
|
$count{$dir} += $n; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
28
|
return \%count; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |