/[smecontribs]/rpms/smeserver-zabbix-agent/contribs9/smeserver-zabbix-agent-0.1-mail_in_stats.patch
ViewVC logotype

Contents of /rpms/smeserver-zabbix-agent/contribs9/smeserver-zabbix-agent-0.1-mail_in_stats.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Feb 9 23:18:26 2016 UTC (8 years, 2 months ago) by stephdl
Branch: MAIN
CVS Tags: smeserver-zabbix-agent-0_1-53_el6_sme, smeserver-zabbix-agent--, HEAD
* Wed Feb 10 stephane de Labrusse <stephdl@de-labrusse.fr> - 0.1-53.sme
- New rpm for sme9

1 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
2 --- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias 2009-02-15 04:34:22.000000000 +0100
3 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/00zabbixAgentAlias 2009-02-15 04:32:05.000000000 +0100
4 @@ -1 +1,2 @@
5 -Cmnd_Alias ZABBIX_AGENT = /usr/bin/mysqladmin status
6 +Cmnd_Alias ZABBIX_AGENT_ROOT = /usr/bin/mysqladmin status
7 +Cmnd_Alias ZABBIX_AGENT_SMELOG = /var/lib/zabbix/bin/logtail.pl /var/log/qpsmtpd/current /var/lib/zabbix/tmp/*
8 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
9 --- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent 2009-02-15 04:34:22.000000000 +0100
10 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/sudoers/30zabbixAgent 2009-02-15 04:32:05.000000000 +0100
11 @@ -1 +1,3 @@
12 -zabbix ALL=(root) NOPASSWD: ZABBIX_AGENT
13 +zabbix ALL=(root) NOPASSWD: ZABBIX_AGENT_ROOT
14 +zabbix ALL=(smelog) NOPASSWD: ZABBIX_AGENT_SMELOG
15 +
16 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
17 --- 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
18 +++ 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
19 @@ -0,0 +1,15 @@
20 +# Incomming mails statistics
21 +
22 +UserParameter=mail.in.denied.dnsbl,/var/lib/zabbix/bin/mail_in.sh dnsbl
23 +UserParameter=mail.in.denied.rhsbl,/var/lib/zabbix/bin/mail_in.sh rhsbl
24 +UserParameter=mail.in.denied.clamav,/var/lib/zabbix/bin/mail_in.sh clamav
25 +UserParameter=mail.in.denied.earlytalker,/var/lib/zabbix/bin/mail_in.sh check_earlytalker
26 +UserParameter=mail.in.denied.basicheaders,/var/lib/zabbix/bin/mail_in.sh check_basicheaders
27 +UserParameter=mail.in.denied.goodrcptto,/var/lib/zabbix/bin/mail_in.sh check_goodrcptto
28 +UserParameter=mail.in.denied.spamhelo,/var/lib/zabbix/bin/mail_in.sh check_spamhelo
29 +UserParameter=mail.in.denied.total,/var/lib/zabbix/bin/mail_in.sh total_denied
30 +UserParameter=mail.in.denied.spam,/var/lib/zabbix/bin/mail_in.sh spam_denied
31 +UserParameter=mail.in.queued.spam,/var/lib/zabbix/bin/mail_in.sh spam_queued
32 +UserParameter=mail.in.queued,/var/lib/zabbix/bin/mail_in.sh queued
33 +UserParameter=mail.in.total,/var/lib/zabbix/bin/mail_in.sh total
34 +
35 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
36 --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/logtail.pl 1970-01-01 01:00:00.000000000 +0100
37 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/logtail.pl 2009-02-15 04:34:09.000000000 +0100
38 @@ -0,0 +1,95 @@
39 +#!/usr/bin/perl
40 +
41 +# Copyright (C) 2009 Daniel Berteaud <daniel@firewall-services.com>
42 +# Copyright (C) 2003 Jonathan Middleton <jjm@ixtab.org.uk
43 +# Copyright (C) 2001 Paul Slootman <paul@debian.org>
44 +
45 +# This file is part of Logcheck.
46 +
47 +# Modifications for integration with smeserver-zabbix-agent
48 +
49 +# Logcheck is free software; you can redistribute it and/or modify
50 +# it under the terms of the GNU General Public License as published by
51 +# the Free Software Foundation; either version 2 of the License, or
52 +# (at your option) any later version.
53 +
54 +# Logcheck is distributed in the hope that it will be useful,
55 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
56 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 +# GNU General Public License for more details.
58 +
59 +# You should have received a copy of the GNU General Public License
60 +# along with Foobar; if not, write to the Free Software
61 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
62 +
63 +my ($logfile, $offsetfile) = @ARGV;
64 +if (! -f $logfile) {
65 + print "File $logfile cannot be read.\n";
66 + exit 66;
67 +}
68 +unless ($offsetfile) {
69 + # offsetfile not given, use .offset/$logfile in the same directory
70 + $offsetfile = $logfile . '.offset';
71 +}
72 +
73 +unless (open(LOGFILE, $logfile)) {
74 + print "File $logfile cannot be read.\n";
75 + exit 66;
76 +}
77 +
78 +my ($inode, $offset) = (0, 0);
79 +
80 +if (open(OFFSET, $offsetfile)) {
81 + $_ = <OFFSET>;
82 + unless (! defined $_) {
83 + chomp $_;
84 + $inode = $_;
85 + $_ = <OFFSET>;
86 + unless (! defined $_) {
87 + chomp $_;
88 + $offset = $_;
89 + }
90 + }
91 +}
92 +
93 +my ($ino, $size);
94 +unless ((undef,$ino,undef,undef,undef,undef,undef,$size) = stat $logfile) {
95 + print "Cannot get $logfile file size.\n", $logfile;
96 + exit 65;
97 +}
98 +
99 +if ($inode == $ino) {
100 + exit 0 if $offset == $size; # short cut
101 + if ($offset > $size) {
102 + $offset = 0;
103 + #print "***************\n";
104 + #print "*** WARNING ***: Log file $logfile is smaller than last time checked!\n";
105 + #print "*************** This could indicate tampering.\n";
106 + }
107 +}
108 +if ($inode != $ino || $offset > $size) {
109 + $offset = 0;
110 +}
111 +
112 +seek(LOGFILE, $offset, 0);
113 +
114 +while (<LOGFILE>) {
115 + print $_;
116 +}
117 +
118 +$size = tell LOGFILE;
119 +close LOGFILE;
120 +
121 +unless (open(OFFSET, ">$offsetfile")) {
122 + print "File $offsetfile cannot be created. Check your permissions.\n";
123 + exit 73;
124 +}
125 +unless (chmod 0600, $offsetfile) {
126 + print "Cannot set permissions on file $offsetfile\n";
127 + exit 65;
128 +}
129 +print OFFSET "$ino\n$size\n";
130 +close OFFSET;
131 +
132 +exit 0;
133 +
134 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
135 --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mail_in.sh 1970-01-01 01:00:00.000000000 +0100
136 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mail_in.sh 2009-02-15 04:32:05.000000000 +0100
137 @@ -0,0 +1,11 @@
138 +#!/bin/bash
139 +WHAT=$1
140 +BINDIR='/var/lib/zabbix/bin'
141 +LOGTAIL=$BINDIR'/logtail.pl'
142 +PARSER=$BINDIR'/parse_mail_in.pl'
143 +LOGFILE='/var/log/qpsmtpd/current'
144 +TMPDIR='/var/lib/zabbix/tmp'
145 +
146 +/usr/bin/sudo -u smelog $LOGTAIL $LOGFILE $TMPDIR/mailin.$WHAT.offset | $PARSER $WHAT
147 +
148 +
149 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
150 --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/parse_mail_in.pl 1970-01-01 01:00:00.000000000 +0100
151 +++ mezzanine_patched_smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/parse_mail_in.pl 2009-02-15 04:32:05.000000000 +0100
152 @@ -0,0 +1,103 @@
153 +#!/usr/bin/perl -w
154 +
155 +# Copyright (C) 2009 Daniel Berteaud <daniel@firewall-services.com>
156 +
157 +# This file is part of smeserver-zabbix-agent package.
158 +
159 +# This script is free software; you can redistribute it and/or modify
160 +# it under the terms of the GNU General Public License as published by
161 +# the Free Software Foundation; either version 2 of the License, or
162 +# (at your option) any later version.
163 +
164 +# This script is distributed in the hope that it will be useful,
165 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
166 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
167 +# GNU General Public License for more details.
168 +
169 +# You should have received a copy of the GNU General Public License
170 +# along with Foobar; if not, write to the Free Software
171 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
172 +
173 +
174 +my $what = $ARGV[0] || '';
175 +
176 +# On initialise nos compteurs a 0
177 +my @denied = qw(dnsbl rhsbl clamav check_earlytalker check_basicheaders check_goodrcptto check_spamhelo);
178 +my @others = qw(total_denied spam_denied spam_queued queued total);
179 +my %cnt;
180 +foreach (@denied,@others){
181 + $cnt{$_} = 0;
182 +}
183 +
184 +while (<STDIN>) {
185 + my $line = $_;
186 +
187 + # on limites aux lignes concernant logterse
188 + # @400000004994ad092afa867c 18386 logging::logterse plugin: etc...
189 + next unless $line =~ m/^\@[0-9a-f]{24} \d+ logging::logterse plugin:/;
190 +
191 + # D'abord on traite tout ceux qui contiennent 'msg denied before queued'
192 + if ($line =~ m/msg denied before queued/){
193 + $cnt{total_denied}++;
194 + foreach (@denied){
195 + if ($line =~ m/$_/){
196 + $cnt{$_}++;
197 + }
198 + }
199 + next;
200 + }
201 +
202 + # Les messages refuses par spamassassin
203 + elsif ($line =~ m/spam score exceeded threshold/){
204 + $cnt{spam_denied}++;
205 + next;
206 + }
207 +
208 + # Spam mis en queue
209 + elsif ($line =~ m/queued.*Yes/){
210 + $cnt{spam_queued}++;
211 + next;
212 + }
213 +
214 + # Enfin, les bon mails
215 + elsif ($line =~ m/queued.*No/){
216 + $cnt{queued}++;
217 + next;
218 + }
219 +}
220 +
221 +# Caclul des totaux:
222 +$cnt{other_denied} = $cnt{total_denied};
223 +foreach (@denied){
224 + $cnt{total} = $cnt{total} + $cnt{$_};
225 + $cnt{other_denied} = $cnt{other_denied} - $cnt{$_};
226 +}
227 +foreach (@others){
228 + $cnt{total} = $cnt{total} + $cnt{$_} if ($_ !~ /total/);
229 +}
230 +
231 +# Si l'argument est "print" on affiche toutes les stats
232 +if ($what eq "print"){
233 +
234 + foreach (@denied,@others){
235 + print "$_: $cnt{$_}\n";
236 + }
237 +}
238 +
239 +# Si l'argument correspond a un compteur definit
240 +# On affiche uniquemment cette valeur
241 +elsif (defined $cnt{$what}){
242 + print "$cnt{$what}\n";
243 +}
244 +
245 +# Sinon, on quitte avec une erreur
246 +else{
247 + print "supported items are: ";
248 + foreach (@denied, @others){
249 + print "$_ ";
250 + }
251 + print "\n";
252 + exit 1;
253 +}
254 +exit 0;
255 +

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed