Compat with qpsmtpd 0.96 logs

Also add some more plugins support
tags/smeserver-zabbix-agent-0.4.3-1
Daniel Berteaud 9 years ago
parent ddbf6d7b48
commit a6074b8ca2
  1. 35
      root/var/lib/zabbix/bin/util_parse_mail_in

@ -1,6 +1,6 @@
#!/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.
@ -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,13 +49,14 @@ while (<STDIN>) {
# 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/$_/){
foreach (keys %denied){
if ($line =~ m/$denied{$_}/){
$cnt{$_}++;
}
}
@ -68,7 +84,7 @@ while (<STDIN>) {
# 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){
foreach (keys %denied, @others){
print "$_ ";
}
print "\n";
exit 1;
}
exit 0;

Loading…
Cancel
Save