From: eldy <> Date: Wed, 10 Sep 2003 12:25:31 +0000 (+0000) Subject: maillogconvert support more exotic sendmail log files X-Git-Tag: AWSTATS_WEBMIN_1_0_RELEASE~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=785514efef0fcd82434d2407c50e3d64cc74441f;p=thirdparty%2FAWStats.git maillogconvert support more exotic sendmail log files --- diff --git a/docs/awstats_changelog.txt b/docs/awstats_changelog.txt index c8fca7d9..dc764228 100644 --- a/docs/awstats_changelog.txt +++ b/docs/awstats_changelog.txt @@ -10,12 +10,14 @@ Fixes: - Fixed problem of parsing with uabracket and refererquot. - Fixed wrong use of config file in rawlog plugin. - Some changes on maillogconvert.pl: + maillogconvert support more exotic sendmail log files. Fixed pb of '-' in relay hostname. - When a mail is sent to 2 different receivers, report 2 records instead of 1. + When a mail is sent to 2 different receivers, now report 2 records. When a forward is active, report the original receiver, not the "forwarded to". - Fixed not working timezone plugin with 5.7. - Fixed missing propagated configdir parameter when changing month/year. +- Error when loading database pm file with some cygwin perl version. New features/improvements: - Added %lognamequot tag for LogFormat parameter. diff --git a/tools/maillogconvert.pl b/tools/maillogconvert.pl index dfd88da3..58e79941 100644 --- a/tools/maillogconvert.pl +++ b/tools/maillogconvert.pl @@ -259,6 +259,50 @@ while (<>) { debug("For id=$id, found a sendmail error incoming message: code=$entry{$id}{'code'} from=$entry{$id}{'from'} to=$entry{$id}{'to'} relay_s=$entry{$id}{'relay_s'}"); } } + # + # See if we received postfix email bounced error + # + elsif (/stat(us)?=bounced/ ne undef) { + # Example: + # postfix: Sep 9 18:24:23 halley postfix/local[22003]: 12C6413EC9: to=, relay=local, delay=0, status=bounced (unknown user: "etavidian") + my ($mon,$day,$time,$id,$to,$relay_r)=m/(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+[\w\-]+\s+(?:postfix\/(?:local|smtpd|smtp))\[\d+\]:\s+(.*?):\s+to=([^\s,]*)[\s,]+relay=([^\s,]*)/; + $rowid=($id eq 'reject'?999:$id); # id not provided in log, we take 999 + if ($rowid) { + $entry{$rowid}{'code'}="999"; # Unkown error (bounced) + $entry{$rowid}{'to'}=&trim($to); + $entry{$rowid}{'relay_r'}=&trim($relay_r); + $entry{$rowid}{'mon'}=$mon; + $entry{$rowid}{'day'}=$day; + $entry{$rowid}{'time'}=$time; + debug("For id=$rowid, found a postfix bounced incoming message: code=$entry{$rowid}{'code'} to=$entry{$rowid}{'to'} relay_r=$entry{$rowid}{'relay_r'}"); + } + } + + # + # See if we send a sendmail (with ctladdr tag) email + # + elsif(/, ctladdr=/ ne undef) { + # + # Matched outgoing sendmail/postfix message + # + my ($mon,$day,$time,$id,$to,$from)=m/(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+\w+\s+(?:sm-mta|sendmail(?:-out|)|postfix\/(?:local|smtpd|smtp))\[.*?\]:\s+([^:]*):\s+to=(.*?)[,\s]+ctladdr=([^\,\s]*)/; + $rowid=$id; + if (m/\s+relay=([^\s,]*)[\s,]/) { $entry{$id}{'relay_r'}=$1; } + elsif (m/\s+mailer=local/) { $entry{$id}{'relay_r'}='localhost'; } + if (/, stat\=Sent/) { $entry{$id}{'code'}=1; } + elsif (/, stat\=User\s+unknown/) { $entry{$id}{'code'}=550; } + elsif (/, stat\=Local\s+configuration/) { $entry{$id}{'code'}=451; } + elsif (/, stat\=Deferred:\s+(\d*)/) { $entry{$id}{'code'}=$1; } + else { $entry{$id}{'code'}=999; } + $entry{$id}{'mon'}=$mon; + $entry{$id}{'day'}=$day; + $entry{$id}{'time'}=$time; + $entry{$id}{'to'}=&trim($to); + $entry{$id}{'from'}=&trim($from); + $entry{$id}{'size'}='?'; + debug("For id=$id, found a sendmail outgoing message: to=$entry{$id}{'to'} from=$entry{$id}{'from'} size=$entry{$id}{'size'} relay_s=$entry{$id}{'relay_s'}"); + } + # # See if we received sendmail, postfix or qmail email # @@ -281,7 +325,7 @@ while (<>) { # # sm-mta: Jul 28 06:55:13 androneda sm-mta[28877]: h6SDtCtg028877: from=<4cmkh79eob@webtv.net>, size=2556, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA, relay=smtp.easydns.com [205.210.42.50] # postfix: Jul 3 15:32:26 apollon postfix/qmgr[13860]: 08FB63B8A4: from=, size=3302, nrcpt=1 (queue active) - my ($id,$from,$size)=m/\w+\s+\d+\s+\d+:\d+:\d+\s+\w+\s+(?:sm-mta|sendmail|postfix\/qmgr|postfix\/nqmgr)\[\d+\]:\s+(.*?):\s+from=(.*?),\s+size=(.*?),/; + my ($id,$from,$size)=m/\w+\s+\d+\s+\d+:\d+:\d+\s+\w+\s+(?:sm-mta|sendmail(?:-in|)|postfix\/qmgr|postfix\/nqmgr)\[\d+\]:\s+(.*?):\s+from=(.*?),\s+size=(.*?),/; $rowid=$id; if (! $entry{$id}{'code'}) { $entry{$id}{'code'}=1; } # If not already defined, we define it if ($entry{$id}{'from'} ne '<>') { $entry{$id}{'from'}=$from; } @@ -299,7 +343,7 @@ while (<>) { # # Matched arrival sendmail/postfix message # - my ($mon,$day,$time,$id,$to)=m/(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+[\w\-]+\s+(?:sm-mta|sendmail|postfix\/(?:local|smtpd|smtp))\[.*?\]:\s+(.*?):\s+to=(.*?),/; + my ($mon,$day,$time,$id,$to)=m/(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+[\w\-]+\s+(?:sm-mta|sendmail(?:-out|)|postfix\/(?:local|smtpd|smtp))\[.*?\]:\s+(.*?):\s+to=(.*?),/; $rowid=$id; if (m/\s+relay=([^\s,]*)[\s,]/) { $entry{$id}{'relay_r'}=$1; } elsif (m/\s+mailer=local/) { $entry{$id}{'relay_r'}='localhost'; }