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:
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?
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:
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.