什么是相当于sendmail -bp
的后缀?
或者,less打字:
mailq
qshape活跃
将显示发送到每个域的电子邮件数量以及它们在活动队列中的时间
q形推迟
将显示相同的,但延期队列
postqueue -p
这是我使用,从后缀邮件列表中挑选。 我删除了作者的名字,以防他不想在这里(你可以从源头上看到它)。 它只显示总计。
#!/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");
编辑:修复26行错字。
postqueue -p | tail -n 1
postqueue -p
中的最后一行postqueue -p
显示了多less请求和大小:
-- 317788 Kbytes in 11860 Requests.
如果你没有qshape
你可以通过下面的yum命令安装它:
yum groupinstall perl development
yum install postfix-perl-scripts
qshape打印Postfix队列域和年龄分布信息。 你可以在这里阅读更多
http://www.postfix.org/QSHAPE_README.html
% qshape -s hold | head T 5 10 20 40 80 160 320 640 1280 1280+ TOTAL 486 0 0 1 0 0 2 4 20 40 419 yahoo.com 14 0 0 1 0 0 0 0 1 0 12 extremepricecuts.net 13 0 0 0 0 0 0 0 2 0 11 ms35.hinet.net 12 0 0 0 0 0 0 0 0 1 11 winnersdaily.net 12 0 0 0 0 0 0 0 2 0 10 hotmail.com 11 0 0 0 0 0 0 0 0 1 10 worldnet.fr 6 0 0 0 0 0 0 0 0 0 6 ms41.hinet.net 6 0 0 0 0 0 0 0 0 0 6 osn.de 5 0 0 0 0 0 1 0 0 0 4
[root @ server〜]#time mailq | grep -c'^ [0-9A-Z]'
10
真正的0m1.333s
用户0m0.003s
sys 0m0.003s
(以上结果表明有10封邮件是队列)
这是一个例子。
#!/bin/bash for q in maildrop incoming active defer deferred do count=$(find /var/spool/postfix/$q ! -type d -print | wc -l) echo $q $count done