Compat with qpsmtpd 0.96 logs
Also add some more plugins support
This commit is contained in:
parent
ddbf6d7b48
commit
a6074b8ca2
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
# Copyright (C) 2009 Daniel Berteaud <daniel@firewall-services.com>
|
# Copyright (C) 2009-2016 Daniel Berteaud <daniel@firewall-services.com>
|
||||||
|
|
||||||
# This file is part of smeserver-zabbix-agent package.
|
# This file is part of smeserver-zabbix-agent package.
|
||||||
|
|
||||||
|
@ -22,10 +22,25 @@
|
||||||
my $what = $ARGV[0] || '';
|
my $what = $ARGV[0] || '';
|
||||||
|
|
||||||
# On initialise nos compteurs a 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 @others = qw(total_denied spam_denied other_denied spam_queued queued total);
|
||||||
my %cnt;
|
my %cnt;
|
||||||
foreach (@denied,@others){
|
foreach (keys %denied, @others){
|
||||||
$cnt{$_} = 0;
|
$cnt{$_} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,23 +49,24 @@ while (<STDIN>) {
|
||||||
|
|
||||||
# on limites aux lignes concernant logterse
|
# on limites aux lignes concernant logterse
|
||||||
# @400000004994ad092afa867c 18386 logging::logterse plugin: etc...
|
# @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'
|
# D'abord on traite tout ceux qui contiennent 'msg denied before queued'
|
||||||
if ($line =~ m/msg denied before queued/){
|
if ($line =~ m/msg denied before queued/){
|
||||||
$cnt{total_denied}++;
|
$cnt{total_denied}++;
|
||||||
foreach (@denied){
|
foreach (keys %denied){
|
||||||
if ($line =~ m/$_/){
|
if ($line =~ m/$denied{$_}/){
|
||||||
$cnt{$_}++;
|
$cnt{$_}++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Les messages refuses par spamassassin
|
# Les messages refuses par spamassassin
|
||||||
elsif ($line =~ m/spam score exceeded threshold/){
|
elsif ($line =~ m/spam score exceeded threshold/){
|
||||||
$cnt{spam_denied}++;
|
$cnt{spam_denied}++;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Spam mis en queue
|
# Spam mis en queue
|
||||||
|
@ -68,7 +84,7 @@ while (<STDIN>) {
|
||||||
|
|
||||||
# Caclul des totaux:
|
# Caclul des totaux:
|
||||||
$cnt{other_denied} = $cnt{total_denied};
|
$cnt{other_denied} = $cnt{total_denied};
|
||||||
foreach (@denied){
|
foreach (keys %denied){
|
||||||
$cnt{total} = $cnt{total} + $cnt{$_};
|
$cnt{total} = $cnt{total} + $cnt{$_};
|
||||||
$cnt{other_denied} = $cnt{other_denied} - $cnt{$_};
|
$cnt{other_denied} = $cnt{other_denied} - $cnt{$_};
|
||||||
}
|
}
|
||||||
|
@ -79,7 +95,7 @@ foreach (@others){
|
||||||
# Si l'argument est "print" on affiche toutes les stats
|
# Si l'argument est "print" on affiche toutes les stats
|
||||||
if ($what eq "print"){
|
if ($what eq "print"){
|
||||||
|
|
||||||
foreach (@denied,@others){
|
foreach (keys %denied,@others){
|
||||||
print "$_: $cnt{$_}\n";
|
print "$_: $cnt{$_}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,11 +109,10 @@ elsif (defined $cnt{$what}){
|
||||||
# Sinon, on quitte avec une erreur
|
# Sinon, on quitte avec une erreur
|
||||||
else{
|
else{
|
||||||
print "supported items are: ";
|
print "supported items are: ";
|
||||||
foreach (@denied, @others){
|
foreach (keys %denied, @others){
|
||||||
print "$_ ";
|
print "$_ ";
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue