diff -Nur -x '*.orig' -x '*.rej' smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias --- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias 2009-02-15 04:34:22.000000000 +0100 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias 2009-02-15 04:32:05.000000000 +0100 @@ -1 +1,2 @@ -Cmnd_Alias ZABBIX_AGENT = /usr/bin/mysqladmin status +Cmnd_Alias ZABBIX_AGENT_ROOT = /usr/bin/mysqladmin status +Cmnd_Alias ZABBIX_AGENT_SMELOG = /var/lib/zabbix/bin/logtail.pl /var/log/qpsmtpd/current /var/lib/zabbix/tmp/* diff -Nur -x '*.orig' -x '*.rej' smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent --- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent 2009-02-15 04:34:22.000000000 +0100 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent 2009-02-15 04:32:05.000000000 +0100 @@ -1 +1,3 @@ -zabbix ALL=(root) NOPASSWD: ZABBIX_AGENT +zabbix ALL=(root) NOPASSWD: ZABBIX_AGENT_ROOT +zabbix ALL=(smelog) NOPASSWD: ZABBIX_AGENT_SMELOG + diff -Nur -x '*.orig' -x '*.rej' smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/90UserParameters_mailIn mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/90UserParameters_mailIn --- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/90UserParameters_mailIn 1970-01-01 01:00:00.000000000 +0100 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/90UserParameters_mailIn 2009-02-15 04:32:05.000000000 +0100 @@ -0,0 +1,15 @@ +# Incomming mails statistics + +UserParameter=mail.in.denied.dnsbl,/var/lib/zabbix/bin/mail_in.sh dnsbl +UserParameter=mail.in.denied.rhsbl,/var/lib/zabbix/bin/mail_in.sh rhsbl +UserParameter=mail.in.denied.clamav,/var/lib/zabbix/bin/mail_in.sh clamav +UserParameter=mail.in.denied.earlytalker,/var/lib/zabbix/bin/mail_in.sh check_earlytalker +UserParameter=mail.in.denied.basicheaders,/var/lib/zabbix/bin/mail_in.sh check_basicheaders +UserParameter=mail.in.denied.goodrcptto,/var/lib/zabbix/bin/mail_in.sh check_goodrcptto +UserParameter=mail.in.denied.spamhelo,/var/lib/zabbix/bin/mail_in.sh check_spamhelo +UserParameter=mail.in.denied.total,/var/lib/zabbix/bin/mail_in.sh total_denied +UserParameter=mail.in.denied.spam,/var/lib/zabbix/bin/mail_in.sh spam_denied +UserParameter=mail.in.queued.spam,/var/lib/zabbix/bin/mail_in.sh spam_queued +UserParameter=mail.in.queued,/var/lib/zabbix/bin/mail_in.sh queued +UserParameter=mail.in.total,/var/lib/zabbix/bin/mail_in.sh total + diff -Nur -x '*.orig' -x '*.rej' smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/logtail.pl mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/logtail.pl --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/logtail.pl 1970-01-01 01:00:00.000000000 +0100 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/logtail.pl 2009-02-15 04:34:09.000000000 +0100 @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# Copyright (C) 2009 Daniel Berteaud +# Copyright (C) 2003 Jonathan Middleton + +# This file is part of Logcheck. + +# Modifications for integration with smeserver-zabbix-agent + +# Logcheck is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# Logcheck is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Foobar; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +my ($logfile, $offsetfile) = @ARGV; +if (! -f $logfile) { + print "File $logfile cannot be read.\n"; + exit 66; +} +unless ($offsetfile) { + # offsetfile not given, use .offset/$logfile in the same directory + $offsetfile = $logfile . '.offset'; +} + +unless (open(LOGFILE, $logfile)) { + print "File $logfile cannot be read.\n"; + exit 66; +} + +my ($inode, $offset) = (0, 0); + +if (open(OFFSET, $offsetfile)) { + $_ = ; + unless (! defined $_) { + chomp $_; + $inode = $_; + $_ = ; + unless (! defined $_) { + chomp $_; + $offset = $_; + } + } +} + +my ($ino, $size); +unless ((undef,$ino,undef,undef,undef,undef,undef,$size) = stat $logfile) { + print "Cannot get $logfile file size.\n", $logfile; + exit 65; +} + +if ($inode == $ino) { + exit 0 if $offset == $size; # short cut + if ($offset > $size) { + $offset = 0; + #print "***************\n"; + #print "*** WARNING ***: Log file $logfile is smaller than last time checked!\n"; + #print "*************** This could indicate tampering.\n"; + } +} +if ($inode != $ino || $offset > $size) { + $offset = 0; +} + +seek(LOGFILE, $offset, 0); + +while () { + print $_; +} + +$size = tell LOGFILE; +close LOGFILE; + +unless (open(OFFSET, ">$offsetfile")) { + print "File $offsetfile cannot be created. Check your permissions.\n"; + exit 73; +} +unless (chmod 0600, $offsetfile) { + print "Cannot set permissions on file $offsetfile\n"; + exit 65; +} +print OFFSET "$ino\n$size\n"; +close OFFSET; + +exit 0; + diff -Nur -x '*.orig' -x '*.rej' smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mail_in.sh mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mail_in.sh --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mail_in.sh 1970-01-01 01:00:00.000000000 +0100 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mail_in.sh 2009-02-15 04:32:05.000000000 +0100 @@ -0,0 +1,11 @@ +#!/bin/bash +WHAT=$1 +BINDIR='/var/lib/zabbix/bin' +LOGTAIL=$BINDIR'/logtail.pl' +PARSER=$BINDIR'/parse_mail_in.pl' +LOGFILE='/var/log/qpsmtpd/current' +TMPDIR='/var/lib/zabbix/tmp' + +/usr/bin/sudo -u smelog $LOGTAIL $LOGFILE $TMPDIR/mailin.$WHAT.offset | $PARSER $WHAT + + diff -Nur -x '*.orig' -x '*.rej' smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/parse_mail_in.pl mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/parse_mail_in.pl --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/parse_mail_in.pl 1970-01-01 01:00:00.000000000 +0100 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/parse_mail_in.pl 2009-02-15 04:32:05.000000000 +0100 @@ -0,0 +1,103 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2009 Daniel Berteaud + +# This file is part of smeserver-zabbix-agent package. + +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This script is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with Foobar; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +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 @others = qw(total_denied spam_denied spam_queued queued total); +my %cnt; +foreach (@denied,@others){ + $cnt{$_} = 0; +} + +while () { + my $line = $_; + + # on limites aux lignes concernant logterse + # @400000004994ad092afa867c 18386 logging::logterse plugin: etc... + next unless $line =~ m/^\@[0-9a-f]{24} \d+ logging::logterse plugin:/; + + # 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; + } + + # Les messages refuses par spamassassin + elsif ($line =~ m/spam score exceeded threshold/){ + $cnt{spam_denied}++; + next; + } + + # Spam mis en queue + elsif ($line =~ m/queued.*Yes/){ + $cnt{spam_queued}++; + next; + } + + # Enfin, les bon mails + elsif ($line =~ m/queued.*No/){ + $cnt{queued}++; + next; + } +} + +# Caclul des totaux: +$cnt{other_denied} = $cnt{total_denied}; +foreach (@denied){ + $cnt{total} = $cnt{total} + $cnt{$_}; + $cnt{other_denied} = $cnt{other_denied} - $cnt{$_}; +} +foreach (@others){ + $cnt{total} = $cnt{total} + $cnt{$_} if ($_ !~ /total/); +} + +# Si l'argument est "print" on affiche toutes les stats +if ($what eq "print"){ + + foreach (@denied,@others){ + print "$_: $cnt{$_}\n"; + } +} + +# Si l'argument correspond a un compteur definit +# On affiche uniquemment cette valeur +elsif (defined $cnt{$what}){ + print "$cnt{$what}\n"; +} + +# Sinon, on quitte avec une erreur +else{ + print "supported items are: "; + foreach (@denied, @others){ + print "$_ "; + } + print "\n"; + exit 1; +} +exit 0; +