Here's what I use, culled from the postfix mailing list. I removed the author's name, in case he doesn't want it here (you can see it at the source). It only displays totals.
#!/usr/bin/env perl
# postfix queue/s size
# author:
# source: http://tech.groups.yahoo.com/group/postfix-users/message/255133
use strict;
use warnings;
use Symbol;
sub count {
my ($dir) = @_;
my $dh = gensym();
my $c = 0;
opendir($dh, $dir) or die "$0: opendir: $dir: $!\n";
while (my $f = readdir($dh)) {
if ($f =~ m{^[A-F0-9]{5,}$}) {
++$c;
} elsif ($f =~ m{^[A-F0-9]$}) {
$c += count("$dir/$f");
}
}
closedir($dh) or die "closedir: $dir: $!\n";
return $c;
}
my $qdir = `postconf -h queue_directory`;
chomp($qdir);
chdir($qdir) or die "$0: chdir: $qdir: $!\n";
printf "Incoming: %d\n", count("incoming");
printf "Active: %d\n", count("active");
printf "Deferred: %d\n", count("deferred");
printf "Bounced: %d\n", count("bounce");
printf "Hold: %d\n", count("hold");
printf "Corrupt: %d\n", count("corrupt");
#!/bin/bash
for q in active bounce corrupt defer deferred flush hold incoming maildrop pid private public saved trace
do
count=$(find /var/spool/postfix/$q ! -type d -print | wc -l)
echo $q $count
done
Or, less typing:
will show you the number of emails being sent to each domain and how long they have been in the active queue
will show you the same but for the deferred queue
Here's what I use, culled from the postfix mailing list. I removed the author's name, in case he doesn't want it here (you can see it at the source). It only displays totals.
EDIT: Fixed a typo on line 26.
postqueue -p | tail -n 1
Last line in the
postqueue -p
shows how many requests and size:-- 317788 Kbytes in 11860 Requests.
[root@server ~]# time mailq | grep -c '^[0-9A-Z]'
10
real 0m1.333s
user 0m0.003s
sys 0m0.003s
(above result indicating that there are 10 email is queue)
If you don't have
qshape
you can install it via the following yum commands:yum groupinstall perl development
yum install postfix-perl-scripts
qshape prints Postfix queue domain and age distribution information. You can read more about it here:
http://www.postfix.org/QSHAPE_README.html
Example output
Here is an example.