On Tuesday 28 February 2006 09:47 am, Sujit Choudhury wrote:
> Hi Everybody,
> We are sometimes getting mail loop and would very much like to find out
> how many mails are in the queue.
> As it is if 80,000 mails are in the queue mailq|wc -l takes very long
> time. Is there any command like exim's exim -bpc which would report the
> number of mails in the queue very quickly?
I have no idea what "exim -bpc" outputs but for rough counts you can use
something like this.
We also have variable versions of this to make it more terse or auto refresh
after X seconds and things like that. Obviously on mail systems with large
amounts of emails you are more prone to have messages moved from one queue to
another by the time your "find" command gets to the other queue so a file
might be counted twice or not counted at all. Run the script a couple of
times, if the $total number turns out to be close each time then it is likely
in=`/usr/bin/find /var/spool/postfix/incoming/ -type f |/usr/bin/wc -l`
active=`/usr/bin/find /var/spool/postfix/active/ -type f |/usr/bin/wc -l`
deferred=`/usr/bin/find /var/spool/postfix/deferred/ -type f |/usr/bin/wc -l`
bounce=`/usr/bin/find /var/spool/postfix/bounce/ -type f |/usr/bin/wc -l`
total=`echo $active + $in + $deferred + $bounce |bc`
echo "Postfix Incoming: $in"
echo "Postfix Active: $active"
echo "Postfix Deferred: $deferred"
echo "Postfix Bounce: $bounce"
echo "Total Queue: $total"