On 31/10/13 18:15, Russell Coker wrote:
> Does anyone know of a good Postfix log file analysis program to find problems 
> with particular users?
>
> In this instance I'm not interested in general statistics or anything.  I 
> just 
> want to do searches such as "all attempts for @gmail.com accounts to send 
> mail 
> to [email protected]" where example.com is a local domain.
>
> The native Postfix logging has one line with a sender address and queue ID 
> and 
> later lines with the queue ID and the recipient(s) which may contain delivery 
> errors.  So I can't just grep for the data I want.
>
> My problem is when I get complains like "[email protected] can't receive mail 
> from [email protected]".  In many cases it's trivial problems that can be 
> difficult to diagnose, such as [email protected] sending mail to 
> [email protected] where user2 has just added the sender to the spam list and 
> not told anyone.  So all parts of the server are working correctly but the 
> users aren't getting what they want.

You can extract details from different log lines and put them on lines
which represent a single email like so:


#!/bin/bash
TO='grep "postfix/smtp.*to=" "'$1'" | awk "{print \$6,\$7}" | sort'
MSGID='grep "postfix/cleanup.*message-id=" "'$1'" | awk "{print
\$6,\$7}" | sort'
FROM='grep "postfix/qmgr.*from=" "'$1'" | awk "{print \$6,\$7}" | sort'
join <(join <(eval $FROM) <(eval $TO) ) <(eval $MSGID)

Run the example script with the name of your log file as an argument.

No doubt this could be done much more efficiently with a single pass
over the log, but this approach is fine for many purposes.

As formulated above, you may get multiple lines relating to the same
email if there are multiple recipients, and also if there are multiple
delivery attempts. Not too hard to work around if it's an issue.

Andrew


_______________________________________________
luv-main mailing list
[email protected]
http://lists.luv.asn.au/listinfo/luv-main

Reply via email to