> On Mar 29, 2016, at 10:45 PM, @lbutlr <[email protected]> wrote: > >> Viktor occasionally posts a script that will allow you to >> combine all logging related to one queue ID. > > I basically want the opposite of that. I want to be able to grep out a single > line for each message that shows all the relevant (to me) information, queue > ID, to from and hopefully orig_to and helo and IP so that I can say something > like:
You're missing the fact the collating messages as paragraphs makes it
easy to "grep" the logs for a complete message, provided one replaces
grep with:
pgrep:
#! /usr/bin/perl
$/="\n\n";
$re=shift;
while (<>) { print if m{$re}o }
So then one can do things like:
# collate /var/log/maillog | pgrep
'<20160329164500\.GD6602@mournblade\.imrryr\.org>'
Mar 29 16:45:00 mournblade postfix/pickup[4089]: 4FF14284F45: uid=1034
from=<[email protected]>
Mar 29 16:45:00 mournblade postfix/cleanup[26776]: 4FF14284F45:
message-id=<[email protected]>
Mar 29 16:45:00 mournblade postfix/qmgr[9946]: 4FF14284F45:
from=<[email protected]>, size=1387, nrcpt=1 (queue active)
Mar 29 16:45:00 mournblade postfix/smtp[7516]: Anonymous TLS connection
established to mail.cloud9.net[168.100.1.4]:25: TLSv1 with cipher
ADH-AES256-SHA (256/256 bits)
Mar 29 16:45:00 mournblade postfix/smtp[7516]: 4FF14284F45:
to=<[email protected]>, relay=mail.cloud9.net[168.100.1.4]:25,
delay=0.25, delays=0.02/0.02/0.16/0.06, dsn=2.0.0, status=sent (250 2.0.0 Ok:
queued as 878833424CF)
Mar 29 16:45:00 mournblade postfix/qmgr[9946]: 4FF14284F45: removed
Mar 29 16:45:07 mournblade postfix/smtpd[21777]: connect from
russian-caravan.cloud9.net[168.100.1.4]
Mar 29 16:45:07 mournblade postfix/smtpd[21777]: Anonymous TLS connection
established from russian-caravan.cloud9.net[168.100.1.4]: TLSv1 with cipher
ADH-AES256-SHA (256/256 bits)
Mar 29 16:45:08 mournblade postfix/smtpd[21777]: 0CB69282F4E:
client=russian-caravan.cloud9.net[168.100.1.4]
Mar 29 16:45:08 mournblade postfix/cleanup[26776]: 0CB69282F4E:
message-id=<[email protected]>
Mar 29 16:45:08 mournblade postfix/qmgr[9946]: 0CB69282F4E:
from=<[email protected]>, size=3606, nrcpt=1 (queue active)
Mar 29 16:45:08 mournblade postfix/virtual[5291]: 0CB69282F4E:
to=<[email protected]>, orig_to=<[email protected]>,
relay=virtual, delay=0.03, delays=0.02/0/0/0.01, dsn=2.0.0, status=sent
(delivered to maildir)
Mar 29 16:45:08 mournblade postfix/qmgr[9946]: 0CB69282F4E: removed
This form of output is much more useful than a single line on message entry...
--
Viktor.
collate
Description: Binary data
