On Mon, 10 Aug 2009 18:20:32 +0200, mouss <mo...@ml.netoyen.net> wrote:
> Clunk Werclick a écrit :
>> Hello,
>> 
>> I have been toying with the best way to produce a report of 'allowed'
>> messages that have made it all the way through my Postfix. I love the
>> Postfix logs, they give such detail on failures and refusals and
parsing
>> this is quite straightforward. 
>> 
>> The entertainment commences when I try to figure out how to produce a
>> report of 'allowed' messages. This needs to contain just a few pieces
of
>> key information;
>> 
>> date/time    from    to      subject         client IP
>> 
>> At first, I thought 'this will be easy' but upon closer examination
this
>> is not as simple as it looks. Where Postfix is multi-process, the bits
>> of information are in different places and consolidating this has some
>> challenges. In particular matching up (by script) the interaction for a
>> transaction between;
>> 
>> postfix/smtpd
>> postfix/cleanup
>> postfix/virtual
>> postfix/qmgr
>> 
>> Perhaps there is an easy way to get the five metrics I would like in a
>> report?
>> 
> 
> do you really want the Subject?
> - what would this be useful for?
> - there may be privacy issues
> - it may be encoded or it may contain "non printable" characters (yes,
> some mailers "forget" to encode...)
> 
> 
> if you don't need the subject, then smtpd restrictions with an action of
> WARN will give you what you want in a single line.
> 
> if you insist on the Subject, you'll need to do some aggregation. start
> by using header_checks to log the Subject. then test by sending a
> message to 1 recipient, and then a message to 2 (or more) recipients.
> this will show you how it is easy to handle in the single recipient
> case, but not in the multi-recipient case.
> 
[SNIP]
>> 
>> Perhaps some of the very clever guru's here have some useful
suggestion?
>> 
>>

With a simple bash script you can find out a lot.

This is my findmsg script the only parameter you need is the Message-Id
without the <>

#!/bin/bash

SEARCH=`grep -E "$1" /var/log/mail.log | \
    awk '{ printf "%s|", $6; }' | \
    sed "s/://g" | \
    sed "s/NOQUEUE|//g" | \
    sed "s/|$//g" | \
    sed "s/message-id=<//g" | \
    sed "s/resent-message-id=<//g" | \
    sed "s/>//g"`

echo $SEARCH

grep -E "$SEARCH" /var/log/mail.log |less

This will give you all log lines for one message. Subject is not included.

And I know this is something that I clobbered together in about 2 mins so
yes it can be optimized.

-- 
Simple things make people happy.
Willy De la Court
PGP Public Key at http://www.linux-lovers.be/download/public_key.asc
PGP Key fingerprint = 784E E18F 7F85 9C7C AC1A D5FB FE08 686C 37C7 A689

Reply via email to