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.