diff --git a/root/var/lib/zabbix/bin/util_parse_mail_in b/root/var/lib/zabbix/bin/util_parse_mail_in index 8815c46..834706a 100644 --- a/root/var/lib/zabbix/bin/util_parse_mail_in +++ b/root/var/lib/zabbix/bin/util_parse_mail_in @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2009 Daniel Berteaud +# Copyright (C) 2009-2016 Daniel Berteaud # This file is part of smeserver-zabbix-agent package. @@ -22,10 +22,25 @@ my $what = $ARGV[0] || ''; # On initialise nos compteurs a 0 -my @denied = qw(dnsbl rhsbl clamav check_earlytalker check_basicheaders check_goodrcptto check_spamhelo); +my %denied = ( + dnsbl => qr{dnsbl\s+90}, + rhsbl => qr{rhsbl\s+90}, + uribl => qr{uribl\s+90}, + clamav => qr{virus::clam(av|dscan)\s+90}, + check_earlytalker => qr{(check_)?earlytalker\s+90}, + check_basicheaders => qr{(check_basic)?headers\s+90}, + check_goodrcptto => qr{(check_)?goodrcptto\s+90}, + check_spamhelo => qr{(check_)?spamhelo\s+90}, + fcrdns => qr{fcrdns\s+90}, + karma => qr{karma\s+90}, + spf => qr{sender_permitted_from\s+90}, + tls_failed => qr{tls\s+90}, + resolvable_fromhost => qr{(require_)?resolvable_fromhost} +); + my @others = qw(total_denied spam_denied other_denied spam_queued queued total); my %cnt; -foreach (@denied,@others){ +foreach (keys %denied, @others){ $cnt{$_} = 0; } @@ -34,23 +49,24 @@ while () { # on limites aux lignes concernant logterse # @400000004994ad092afa867c 18386 logging::logterse plugin: etc... - next unless $line =~ m/^\@[0-9a-f]{24} \d+ logging::logterse plugin/; + # selon la version de qpsmtpd, les lignes logterse peuvent varier + next unless $line =~ m/^\@[0-9a-f]{24} \d+( \((queue|deny)\))? logging::logterse/; # D'abord on traite tout ceux qui contiennent 'msg denied before queued' if ($line =~ m/msg denied before queued/){ - $cnt{total_denied}++; - foreach (@denied){ - if ($line =~ m/$_/){ - $cnt{$_}++; - } - } - next; + $cnt{total_denied}++; + foreach (keys %denied){ + if ($line =~ m/$denied{$_}/){ + $cnt{$_}++; + } + } + next; } # Les messages refuses par spamassassin elsif ($line =~ m/spam score exceeded threshold/){ - $cnt{spam_denied}++; - next; + $cnt{spam_denied}++; + next; } # Spam mis en queue @@ -68,7 +84,7 @@ while () { # Caclul des totaux: $cnt{other_denied} = $cnt{total_denied}; -foreach (@denied){ +foreach (keys %denied){ $cnt{total} = $cnt{total} + $cnt{$_}; $cnt{other_denied} = $cnt{other_denied} - $cnt{$_}; } @@ -79,7 +95,7 @@ foreach (@others){ # Si l'argument est "print" on affiche toutes les stats if ($what eq "print"){ - foreach (@denied,@others){ + foreach (keys %denied,@others){ print "$_: $cnt{$_}\n"; } } @@ -93,11 +109,10 @@ elsif (defined $cnt{$what}){ # Sinon, on quitte avec une erreur else{ print "supported items are: "; - foreach (@denied, @others){ - print "$_ "; + foreach (keys %denied, @others){ + print "$_ "; } print "\n"; exit 1; } exit 0; -