Changeset 522


Ignore:
Timestamp:
Jun 11, 2010, 8:45:27 PM (10 years ago)
Author:
obibi
Message:

"connexion input" functions implemented, see #12.

Location:
postfix-logtools/poststat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • postfix-logtools/poststat/anonymizer.pl

    r521 r522  
    1717
    1818# Anonymizer for Postfix mail logs.
    19 # Usage example : zcat -f /var/log/mail/mail.log* | anonymizer.pl
     19# Usage example :
     20#     zcat -f /var/log/mail/mail.log* | anonymizer.pl --backup-mx mx.backup.server1.com mx.backup.server2.org
    2021
    2122use strict;
     
    2526my @backupmx;
    2627GetOptions("backup-mx=s{,}" => \@backupmx);
     28my $mxlist = join('|',@backupmx) if @backupmx;
    2729
    2830while (<>) {
    2931    # Only keep postfix/* related lines, anonymize mail server's hostname
    30     #and move dates to a fixed offset.
     32    # and move dates to a fixed offset.
    3133    next unless s/^[a-zA-Z]+ +\d+ ([\d:]{8}) \w+ postfix\//Apr 1 $1 host postfix\//;
    3234    # Scramble ip addresses.
     
    3739    s/(message-id)=<.*@.*>/$1=<$1\@domain>/g;
    3840    # Scramble hostnames.
    39     # Is there a smarter way to preserve names of the MX backups servers ?
    40     # and in which lines shall them be preserved ?
    41     # TODO: Rewrite "/from [\w\-\.]*/ && ! /from localhost/" in a unique regex,
    42     # TODO an maybe the whole test in a less obscure way.
    43     #if(/from ([\w\-\.]*)/ and $1 ne 'localhost')
    44     if (/from ([\w\-\.]*/ && ! /from localhost/ && @backupmx) {
    45         foreach my $mx (@backupmx) {
    46             print "#"x80,"\n","$mx\n";
    47             s/(from )[\w\-\.]*/$1hostname/g unless /from $mx/;
    48         }
     41    # TODO: Maybe rewrite the whole test in a less obscure way.
     42    if (/from ([\w\-\.]*)/ && $1 ne 'localhost' && @backupmx) {
     43        s/(from )[\w\-\.]*/$1hostname/g unless /from ($mxlist)/;
    4944    } else {
    5045        s/(from )[\w\-\.]*/$1hostname/g unless /from localhost/;
  • postfix-logtools/poststat/poststat

    r521 r522  
    6262  if ($prog eq 'smtpd') {
    6363    # Incoming SMTP connexions
    64     foreach my $mx (@backupmx) {
    65         $stat{ci_connect_int}++,      next if /^connect from $mx/;
     64    if (@backupmx) {
     65        foreach my $mx (@backupmx) {
     66            $stat{ci_connect_int}++,      next if /^connect from $mx/;
     67        }
    6668    }
    6769    $stat{ci_connect_ext}++,     next if /^connect/;
     
    115117}
    116118
     119#$stat{ci_connect_int} = 0 unless $stat{ci_connect_int} ;
    117120$stat{ci_connect} = $stat{ci_connect_int} + $stat{ci_connect_ext};
    118121printf("%-20s: %u\n", $_, $stat{$_}) foreach sort keys %stat;
Note: See TracChangeset for help on using the changeset viewer.