How to determine queue status

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to determine queue status

Alex Regan
Hi,

I have a postfix-3.5.8 system with amavisd on fedora33. I'm trying to
get an idea of how many emails are queued because they can't be
delivered in a timely manner by analyzing the logs, instead of just
periodically running "mailq" in a script. Is this possible?

This log entry, for example, appears to show this email was queued
before being processed:

Jan 17 00:00:20 armor postfix/qmgr[1249324]: ABD1C3A3D87:
from=<3vMIDYA4KBVcCDI74N-CDG3EAN5DD5A3.1DBPQQQW6DI3A.03HIL3HI3GC.1DB@chime-n
otifications.bounces.google.com>, size=34580, nrcpt=2 (queue active)

Maybe instead it should be "deferred" messages?

Jan 17 07:02:50 cipher postfix/smtp[2027771]: EC93D288102BB:
to=<[hidden email]>, orig_to=<[hidden email]>, relay=none,
delay=130746, delays=130716/0.01/30/0, dsn=4.4.1, status=deferred
(connect to google.com[91.195.240.117]:25: Connection timed out)

I'm trying to get a count of all deferred/queued messages pending
delivery over a period of time, such as the last hour, if I can query
the logs to find this. I suppose I could also check the number of
files in /var/spool/postfix/deferred, but aren't there also times
where the "active" queue is some non-zero number?
Reply | Threaded
Open this post in threaded view
|

Re: How to determine queue status

Viktor Dukhovni
On Sun, Jan 17, 2021 at 11:02:51AM -0500, Alex wrote:

> I have a postfix-3.5.8 system with amavisd on fedora33. I'm trying to
> get an idea of how many emails are queued because they can't be
> delivered in a timely manner by analyzing the logs, instead of just
> periodically running "mailq" in a script. Is this possible?

Given lossless logs, you can count the number of messages accepted
as logged by "cleanup":

    postfix/cleanup: <queue-id>: message-id=...

and the number of messages removed because all recipients
are either delivered or bounced:

    postfix/qmgr: <queue-id>: removed

The difference between the two is the number of messages still in the
queue.  However, this is a very crude metric it is not clear that this
is useful.  For a more usable queue status report, see:

    http://www.postfix.org/QSHAPE_README.html

Just counting logged queue entries/removals is subject to drift if some
syslog messages are lost.  To address drift you'd want to actually keep
track of "live" queue-id, and drop them from the list if they're too
old, even absent a "removed" log entry.

--
    Viktor.