Changeset 521


Ignore:
Timestamp:
Jun 10, 2010, 9:13:50 PM (10 years ago)
Author:
obibi
Message:

Continuing work on MX backup option, see #12.

Location:
postfix-logtools/poststat
Files:
2 edited

Legend:

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

    r504 r521  
    11#!/usr/bin/env perl
    22
    3 # 2010-05-05 <vschmitt@bearstech.com>
     3# 2010-06-09 <vschmitt@bearstech.com>
    44
    55# This program is free software: you can redistribute it and/or modify
     
    2121use strict;
    2222use warnings;
     23use Getopt::Long;
     24
     25my @backupmx;
     26GetOptions("backup-mx=s{,}" => \@backupmx);
    2327
    2428while (<>) {
    25     # Only keep postfix/* related lines, anonynize mail server's hostname
     29    # Only keep postfix/* related lines, anonymize mail server's hostname
    2630    #and move dates to a fixed offset.
    27     next unless s/^[a-zA-Z]+ \d+ ([\d:]{8}) \w+ postfix\//Apr 1 $1 host postfix\//;
     31    next unless s/^[a-zA-Z]+ +\d+ ([\d:]{8}) \w+ postfix\//Apr 1 $1 host postfix\//;
    2832    # Scramble ip addresses.
    2933    s| (([\d]{1,3}\.){3}[\d]{1,3}) | join('.', map {int($_/3)} split(/\./, $1)) |gex;
     
    3337    s/(message-id)=<.*@.*>/$1=<$1\@domain>/g;
    3438    # Scramble hostnames.
    35     s/(hostname |from |connect to |client=|relay=)[\w\-\.]*/$1hostname/g
    36         unless /(hostname |from |client=|relay=)(localhost|ns3\.bearstech\.net)/;
     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        }
     49    } else {
     50        s/(from )[\w\-\.]*/$1hostname/g unless /from localhost/;
     51    }
     52    s/(hostname |connect to |client=|relay=)[\w\-\.]*/$1hostname/g
     53        unless /(hostname |client=|relay=)localhost/;
    3754    s/(helo=<).*>/$1hostname>/;
    3855    s/<[^<]*>:/<hostname_or_email_address>:/g;
  • postfix-logtools/poststat/poststat

    r509 r521  
    11#!/usr/bin/perl
    22
     3# 2010-06-07 vschmitt@bearstech.com
    34# 2009-04-23 vcaron@bearstech.com
     5
     6# This program is free software: you can redistribute it and/or modify
     7# it under the terms of the GNU General Public License as published by
     8# the Free Software Foundation, either version 3 of the License, or
     9# (at your option) any later version.
     10#
     11# This program is distributed in the hope that it will be useful,
     12# but WITHOUT ANY WARRANTY; without even the implied warranty of
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14# GNU General Public License for more details.
     15#
     16# You should have received a copy of the GNU General Public License
     17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
     18
    419# Grep Postfix logs and gather various counters in JSON format,
    520# one file per counter (useful to feed to some Flotr based graph)
    6 
    721# Note:
    822# - no real need to filter ou mon probes (24 checks/day)
     
    1125use strict;
    1226use warnings;
    13 #use Getopt::Long;
     27use Getopt::Long;
    1428
    1529my @probes = qw/
     
    3852/;
    3953my %stat;
     54my @backupmx;
     55GetOptions("backup-mx=s{,}" => \@backupmx);
    4056
    4157while (<STDIN>) {
     
    4662  if ($prog eq 'smtpd') {
    4763    # Incoming SMTP connexions
    48     # TODO: Define the MX backups servers (use getopt).
    49     # TODO: Edit the anonymizer to keep the MX backups servers in the logs.
    50     $stat{ci_connect_int}++,      next if /^connect from tooty\.bearstech\.com/;
     64    foreach my $mx (@backupmx) {
     65        $stat{ci_connect_int}++,      next if /^connect from $mx/;
     66    }
    5167    $stat{ci_connect_ext}++,     next if /^connect/;
    5268    # Don't count local connections, most of them are reinjections from a/v
Note: See TracChangeset for help on using the changeset viewer.