git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ssh://git.exim.org/home/git/exim
[exim.git]
/
src
/
src
/
exiqsumm.src
diff --git
a/src/src/exiqsumm.src
b/src/src/exiqsumm.src
index 00cd23152f6af2e2117d6ec4d58a95a63384bd2c..fc5ad26bb56009e6f2484402f842221ec21dede6 100644
(file)
--- a/
src/src/exiqsumm.src
+++ b/
src/src/exiqsumm.src
@@
-1,5
+1,4
@@
#! PERL_COMMAND -w
#! PERL_COMMAND -w
-# $Cambridge: exim/src/src/exiqsumm.src,v 1.1 2004/10/07 10:39:01 ph10 Exp $
# Mail Queue Summary
# Christoph Lameter, 21 May 1997
# Mail Queue Summary
# Christoph Lameter, 21 May 1997
@@
-26,11
+25,19
@@
# message ID ends in 'D'! Before Exim 4.14 this didn't
# matter because they never did. Looks like an original
# typo. Fix provided by Chris Liddiard.
# message ID ends in 'D'! Before Exim 4.14 this didn't
# matter because they never did. Looks like an original
# typo. Fix provided by Chris Liddiard.
+# November 2006 by Jori Hamalainen
+# Added feature to separate frozen and bounced messages from queue
+# Adedd feature to list queue per source - destination pair
+# Changed regexps to compile once to very minor speed optimization
+# Short circuit for empty lines
#
#
-# Usage: mailq | exiqsumm [-a] [-
c
]
+# Usage: mailq | exiqsumm [-a] [-
b] [-c] [-f] [-s
]
# Default sorting is by domain name
# -a sorts by age of oldest message
# Default sorting is by domain name
# -a sorts by age of oldest message
+# -b enables bounce message separation
# -c sorts by count of message
# -c sorts by count of message
+# -f enables frozen message separation
+# -s enables source destination separation
# Slightly modified sub from eximstats
# Slightly modified sub from eximstats
@@
-52,7
+59,7
@@
else
sub s_conv {
my($x) = @_;
sub s_conv {
my($x) = @_;
- my($v,$s) = $x =~ /([\d\.]+)([A-Z]|)/;
+ my($v,$s) = $x =~ /([\d\.]+)([A-Z]|)/
o
;
if ($s eq "K") { return $v * 1024 };
if ($s eq "M") { return $v * 1024 * 1024 };
return $v;
if ($s eq "K") { return $v * 1024 };
if ($s eq "M") { return $v * 1024 * 1024 };
return $v;
@@
-60,8
+67,8
@@
sub s_conv {
sub older {
my($x1,$x2) = @_;
sub older {
my($x1,$x2) = @_;
- my($v1,$s1) = $x1 =~ /(\d+)(\w)/;
- my($v2,$s2) = $x2 =~ /(\d+)(\w)/;
+ my($v1,$s1) = $x1 =~ /(\d+)(\w)/
o
;
+ my($v2,$s2) = $x2 =~ /(\d+)(\w)/
o
;
return $v1 <=> $v2 if ($s1 eq $s2);
return (($s2 eq "m") ||
($s2 eq "h" && $s1 eq "d") ||
return $v1 <=> $v2 if ($s1 eq $s2);
return (($s2 eq "m") ||
($s2 eq "h" && $s1 eq "d") ||
@@
-84,29
+91,41
@@
while (@ARGV > 0 && substr($ARGV[0], 0, 1) eq "-")
{
if ($ARGV[0] eq "-a") { $sort_by_age = 1; }
if ($ARGV[0] eq "-c") { $sort_by_count = 1; }
{
if ($ARGV[0] eq "-a") { $sort_by_age = 1; }
if ($ARGV[0] eq "-c") { $sort_by_count = 1; }
+ if ($ARGV[0] eq "-f") { $enable_frozen = 1; }
+ if ($ARGV[0] eq "-b") { $enable_bounces = 1; }
+ if ($ARGV[0] eq "-s") { $enable_source = 1; }
shift @ARGV;
}
while (<>)
{
shift @ARGV;
}
while (<>)
{
-# Skip already delivered lines
+# Skip
empty and
already delivered lines
-if (/^
\s*D\s\S+/
) { next; }
+if (/^
$/o || /^\s*D\s\S+/o
) { next; }
# If it's the first line of a message, pick out the data. Note: it may
# have text after the final > (e.g. frozen) so don't insist that it ends >.
# If it's the first line of a message, pick out the data. Note: it may
# have text after the final > (e.g. frozen) so don't insist that it ends >.
-if (/^([\d\s]{2,3}\w)\s+(\S+)\s(\S+)\s\<(\S*)\>/)
+if (/^([\d\s]{2,3}\w)\s+(\S+)\s(\S+)\s\<(\S*)\>/
o
)
{
{
- ($age,$size,$id)=($1,$2,$3);
+ ($age,$size,$id,$src)=($1,$2,$3,$4);
+ $src =~ s/([^\@]*)\@(.*?)$/$2/o;
+ if (/\*\*\*\sfrozen\s\*\*\*/o) { $frozen=1; } else { $frozen=0; }
+ if ($src eq "") { $bounce=1; $src="<>"; } else { $bounce=0; }
}
# Else check for a recipient line: to handle source-routed addresses, just
# pick off the first domain.
}
# Else check for a recipient line: to handle source-routed addresses, just
# pick off the first domain.
-elsif (/^\s+[^@]*\@([\w\.\-]+|\[(\d+\.){3}\d+\])/)
+elsif (/^\s+[^@]*\@([\w\.\-]+|\[(\d+\.){3}\d+\])/
o
)
{
{
- $domain = "\L$1";
+ if ($enable_source) {
+ $domain = "\L$src > $1";
+ } else {
+ $domain = "\L$1";
+ }
+ $domain .= " (b)" if ($bounce && $enable_bounces);
+ $domain .= " (f)" if ($frozen && $enable_frozen);
$queue{$domain}++;
$q_oldest{$domain} = $age
if (!defined $q_oldest{$domain} || &older($age,$q_oldest{$domain}) > 0);
$queue{$domain}++;
$q_oldest{$domain} = $age
if (!defined $q_oldest{$domain} || &older($age,$q_oldest{$domain}) > 0);
@@
-120,7
+139,7
@@
elsif (/^\s+[^@]*\@([\w\.\-]+|\[(\d+\.){3}\d+\])/)
print "\nCount Volume Oldest Newest Domain";
print "\n----- ------ ------ ------ ------\n\n";
print "\nCount Volume Oldest Newest Domain";
print "\n----- ------ ------ ------ ------\n\n";
-my ($count, $volume, $max_age, $min_age) = (0, 0, "0m",
"0000d"
);
+my ($count, $volume, $max_age, $min_age) = (0, 0, "0m",
undef
);
foreach $id (sort
{
foreach $id (sort
{
@@
-134,10
+153,12
@@
foreach $id (sort
$queue{$id}, &print_volume_rounded($q_size{$id}), $q_oldest{$id},
$q_recent{$id}, $id);
$max_age = $q_oldest{$id} if &older($q_oldest{$id}, $max_age) > 0;
$queue{$id}, &print_volume_rounded($q_size{$id}), $q_oldest{$id},
$q_recent{$id}, $id);
$max_age = $q_oldest{$id} if &older($q_oldest{$id}, $max_age) > 0;
- $min_age = $q_recent{$id} if &older($min_age, $q_recent{$id}) > 0;
+ $min_age = $q_recent{$id}
+ if (!defined $min_age || &older($min_age, $q_recent{$id}) > 0);
$volume += $q_size{$id};
$count += $queue{$id};
}
$volume += $q_size{$id};
$count += $queue{$id};
}
+ $min_age ||= "0000d";
printf("---------------------------------------------------------------\n");
printf("%5d %.6s %6s %6s %.80s\n",
$count, &print_volume_rounded($volume), $max_age, $min_age, "TOTAL");
printf("---------------------------------------------------------------\n");
printf("%5d %.6s %6s %6s %.80s\n",
$count, &print_volume_rounded($volume), $max_age, $min_age, "TOTAL");