Changeset 536


Ignore:
Timestamp:
Jun 28, 2010, 7:15:00 PM (10 years ago)
Author:
obibi
Message:

Draft to fix the last counters, see #12.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postfix-logtools/poststat/poststat

    r524 r536  
    1 #!/usr/bin/perl
     1#!/usr/bin/env perl
    22
    3 # 2010-06-07 vschmitt@bearstech.com
     3# 2010-06-26 vschmitt@bearstech.com
    44# 2009-04-23 vcaron@bearstech.com
    55
     
    5555my @backupmx;
    5656GetOptions("backup-mx=s{,}" => \@backupmx);
    57 $stat{ci_connect_int} = 0 unless @backupmx;
     57$stat{ci_connect_int} = 0;
    5858
    5959while (<STDIN>) {
     
    6969        }
    7070    }
     71    $stat{ci_connect_local}++,   next if /^connect from localhost/;
    7172    $stat{ci_connect_ext}++,     next if /^connect/;
    72     # Don't count local connections, most of them are reinjections from a/v
    73     #$stat{ci_connect_local}++,   next if /^connect from localhost/;
    7473
    7574    # Rejected connexions (no delivery)
     
    7877    $stat{ce_helo_not_fqdn}++,   next if /Helo command rejected: need fully-qualified hostname/;
    7978    $stat{ce_helo_no_dns}++,     next if /Helo command rejected: Host not found/;
     79    # FIXME Did never match in tests
     80    # try with /Recipient address rejected/ ?
    8081    $stat{ce_blacklist}++,       next if /Client host rejected/;
    8182    $stat{ce_psbl}++,            next if /blocked using psbl\.surriel\.com/;
     
    8889    $stat{me_no_relay}++,        next if /Relay access denied/;
    8990    $stat{me_no_target}++,       next if /User unknown in (local recipient|virtual mailbox) table/;
     91    # FIXME Did never match in tests
    9092    $stat{me_sender_not_fqdn}++, next if /Sender address rejected: need fully-qualified address/;
    9193    $stat{me_sender_no_dns}++,   next if /Sender address rejected: Domain not found/;
     
    110112  }
    111113
     114  # FIXME Did never match in tests
    112115  if ($prog eq 'virtual') {
    113116    # Messages delivery (output and errors)
     117    # FIXME Did never match in tests
     118    # maybe try to match
     119    # /status=sent (250 2.0.0 Ok/ for transfered mails
     120    # but this one seems to match a lot of transfers
     121    # or
     122    # /status=sent (delivered via dovecot service)/ for local delivery
    114123    $stat{mo_delivered}++,       next if /delivered to maildir/;
    115124    $stat{me_no_target}++,       next if /unknown user:/;
     
    119128}
    120129
    121 $stat{ce_ok} = $stat{ce_hangup} + $stat{ce_helo_no_dns} + $stat{ce_helo_not_fqdn} + $stat{ce_proto_error} + $stat{ce_psbl} + $stat{ce_sorbs} + $stat{ce_spamhaus} + $stat{ce_ssl_error} + $stat{ce_timeout};
    122 $stat{ci_connect} = $stat{ci_connect_int} + $stat{ci_connect_ext};
     130$stat{ci_connect} += $stat{$_} foreach grep {/^ci_/} keys %stat;
     131$stat{ce_ok} += $stat{$_} foreach grep {/^ce_/} keys %stat;
     132
    123133printf("%-20s: %u\n", $_, $stat{$_}) foreach sort keys %stat;
     134
Note: See TracChangeset for help on using the changeset viewer.