]>
Commit | Line | Data |
---|---|---|
a87f3b90 | 1 | diff -urN amavis-stats-0.1.22.orig/configure.in amavis-stats-0.1.22/configure.in |
2 | --- amavis-stats-0.1.22.orig/configure.in 2006-12-04 13:59:29.000000000 +0100 | |
f90afe04 | 3 | +++ amavis-stats-0.1.22/configure.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 4 | @@ -66,7 +66,6 @@ |
5 | AC_PATH_PROG(CP, cp, cp) | |
6 | AC_PATH_PROG(CHMOD, chmod, chmod) | |
7 | AC_PATH_PROG(CHOWN, chown, chown) | |
8 | -AC_PATH_PROGS(GZCAT, gzcat, no) | |
9 | AC_PATH_PROGS(NROFF, gnroff nroff) | |
10 | AC_PATH_PROGS(TROFF, groff troff) | |
11 | AC_PROG_LIBTOOL | |
12 | @@ -101,14 +100,6 @@ | |
044cbf7c | 13 | |
a87f3b90 | 14 | PERL_VERSION=`$PERL -MConfig -e 'print $Config{version}'` |
044cbf7c | 15 | |
a87f3b90 | 16 | -if test "$GZCAT" = no; then |
17 | - AC_MSG_ERROR([ | |
18 | - | |
19 | -gzcat not found!!! | |
20 | - | |
21 | -]) | |
22 | -fi | |
23 | - | |
24 | if test "$PATCH" = no; then | |
25 | AC_MSG_ERROR([ | |
044cbf7c | 26 | |
a87f3b90 | 27 | diff -urN amavis-stats-0.1.22.orig/doc/Makefile.in amavis-stats-0.1.22/doc/Makefile.in |
28 | --- amavis-stats-0.1.22.orig/doc/Makefile.in 2006-12-04 14:00:42.000000000 +0100 | |
f90afe04 | 29 | +++ amavis-stats-0.1.22/doc/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 30 | @@ -108,7 +108,6 @@ |
31 | GCJ = @GCJ@ | |
32 | GCJFLAGS = @GCJFLAGS@ | |
33 | GETENT = @GETENT@ | |
34 | -GZCAT = @GZCAT@ | |
35 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
36 | LIBTOOL = @LIBTOOL@ | |
37 | LINK_CMD = @LINK_CMD@ | |
38 | diff -urN amavis-stats-0.1.22.orig/etc/Makefile.in amavis-stats-0.1.22/etc/Makefile.in | |
39 | --- amavis-stats-0.1.22.orig/etc/Makefile.in 2006-12-04 14:00:44.000000000 +0100 | |
f90afe04 | 40 | +++ amavis-stats-0.1.22/etc/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 41 | @@ -108,7 +108,6 @@ |
42 | GCJ = @GCJ@ | |
43 | GCJFLAGS = @GCJFLAGS@ | |
44 | GETENT = @GETENT@ | |
45 | -GZCAT = @GZCAT@ | |
46 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
47 | LIBTOOL = @LIBTOOL@ | |
48 | LINK_CMD = @LINK_CMD@ | |
49 | diff -urN amavis-stats-0.1.22.orig/Makefile.in amavis-stats-0.1.22/Makefile.in | |
50 | --- amavis-stats-0.1.22.orig/Makefile.in 2006-12-04 13:59:40.000000000 +0100 | |
f90afe04 | 51 | +++ amavis-stats-0.1.22/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 52 | @@ -108,7 +108,6 @@ |
53 | GCJ = @GCJ@ | |
54 | GCJFLAGS = @GCJFLAGS@ | |
55 | GETENT = @GETENT@ | |
56 | -GZCAT = @GZCAT@ | |
57 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
58 | LIBTOOL = @LIBTOOL@ | |
59 | LINK_CMD = @LINK_CMD@ | |
60 | diff -urN amavis-stats-0.1.22.orig/php/Makefile.in amavis-stats-0.1.22/php/Makefile.in | |
61 | --- amavis-stats-0.1.22.orig/php/Makefile.in 2006-12-04 14:00:39.000000000 +0100 | |
f90afe04 | 62 | +++ amavis-stats-0.1.22/php/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 63 | @@ -124,7 +124,6 @@ |
64 | GCJ = @GCJ@ | |
65 | GCJFLAGS = @GCJFLAGS@ | |
66 | GETENT = @GETENT@ | |
67 | -GZCAT = @GZCAT@ | |
68 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
69 | LIBTOOL = @LIBTOOL@ | |
70 | LINK_CMD = @LINK_CMD@ | |
71 | diff -urN amavis-stats-0.1.22.orig/sbin/amavis-stats.in amavis-stats-0.1.22/sbin/amavis-stats.in | |
72 | --- amavis-stats-0.1.22.orig/sbin/amavis-stats.in 2006-01-21 02:25:01.000000000 +0100 | |
f90afe04 | 73 | +++ amavis-stats-0.1.22/sbin/amavis-stats.in 2008-05-12 18:36:55.000000000 +0200 |
a87f3b90 | 74 | @@ -59,6 +59,7 @@ |
75 | Exporter POSIX Fcntl Errno Carp Time::HiRes | |
76 | Unix::Syslog RRDp RRDs IO::File | |
77 | warnings Time::localtime Time::Local | |
78 | + Compress::Zlib | |
79 | )); | |
80 | } | |
044cbf7c | 81 | |
a87f3b90 | 82 | @@ -843,6 +844,7 @@ |
83 | use Unix::Syslog qw(:macros :subs); | |
84 | use IO::File (); | |
85 | use File::Basename; | |
86 | +use Compress::Zlib; | |
87 | ||
88 | BEGIN { | |
89 | import AmavisStats::Conf qw(:platform $myversion $myhostname $daemon_user); | |
f90afe04 | 90 | @@ -1596,6 +1598,56 @@ |
a87f3b90 | 91 | |
92 | } | |
93 | ||
94 | + sub parseFilegz { | |
044cbf7c | 95 | + |
a87f3b90 | 96 | + my ($fname, $start) = @_; |
97 | + do_log(2, "parseFilegz($fname, $start)"); | |
044cbf7c | 98 | + |
a87f3b90 | 99 | + # |
100 | + # Open up the file we need to parse | |
101 | + # | |
f90afe04 | 102 | + my $gz; |
103 | + unless ($gz = gzopen ($fname, "rb")) { | |
a87f3b90 | 104 | + do_log(1, "ERROR : Could not open file $fname: $!"); |
044cbf7c | 105 | + } |
a87f3b90 | 106 | + |
044cbf7c | 107 | + # |
a87f3b90 | 108 | + # Loop each line until the current end of file |
044cbf7c | 109 | + # |
a87f3b90 | 110 | + $pos = 0; |
111 | + while ($pos < $start) { | |
112 | + $pos += $gz->gzreadline($line); | |
044cbf7c | 113 | + } |
044cbf7c | 114 | + |
a87f3b90 | 115 | + my $lineid = 0; |
116 | + my $p = 0; | |
117 | + | |
118 | + do { | |
119 | + $p = $gz->gzreadline($line); | |
120 | + $pos += $p; | |
121 | + | |
122 | + if ($p > 0) { | |
123 | + $lineid++; | |
124 | + $lastepoch = $epoch; | |
044cbf7c | 125 | + |
a87f3b90 | 126 | + if ($line =~ /amavis.*?\[\d+\]:/) { |
127 | + classify(); | |
128 | + } | |
129 | + | |
130 | + # | |
131 | + # Save the current statistics every 1000 lines. This way | |
132 | + # if the program dies we don't have to start again from the | |
133 | + # beginning each time. Also good for monitoring the graphs | |
134 | + # to see where we are up to. | |
135 | + # | |
136 | + if (!($lineid % 1000)) { | |
137 | + saveState();; | |
138 | + } | |
139 | + } | |
140 | + } while $p > 0; | |
141 | + $gz->gzclose(); | |
142 | + } | |
143 | + | |
144 | sub parseRotFile { | |
145 | do_log(5, "DEBUG : parseRotFile()"); | |
146 | my ($scan_logfile, $spos) = @_; | |
f90afe04 | 147 | @@ -1614,25 +1666,65 @@ |
044cbf7c | 148 | |
a87f3b90 | 149 | my $rotlogfile = undef; |
044cbf7c | 150 | |
a87f3b90 | 151 | - if (! -f "$scan_logfile.0" && -f "$scan_logfile.0.gz" ) { |
152 | - do_log(2 , "copying $scan_logfile.0.gz -> $scan_logfile.0"); | |
153 | - `gzcat "$scan_logfile.0.gz" > "$scan_logfile.0"`; | |
154 | - } | |
155 | - | |
156 | if (-f "$scan_logfile.0") { | |
157 | $rotlogfile = $scan_logfile . ".0"; | |
158 | + } elsif (-f "$scan_logfile.0.gz") { | |
159 | + $rotlogfile = $scan_logfile . ".0.gz"; | |
160 | } elsif (-f "$scan_logfile.1") { | |
161 | $rotlogfile = $scan_logfile . ".1"; | |
162 | + } elsif (-f "$scan_logfile.1.gz") { | |
163 | + $rotlogfile = $scan_logfile . ".1.gz"; | |
164 | } elsif (-f "$scan_logfile.01") { | |
165 | $rotlogfile = $scan_logfile . ".01"; | |
166 | + } elsif (-f "$scan_logfile.01.gz") { | |
167 | + $rotlogfile = $scan_logfile . ".01.gz"; | |
168 | } elsif (-f "$scan_logfile-$today") { | |
169 | $rotlogfile = $scan_logfile . "-$today"; | |
170 | + } elsif (-f "$scan_logfile-$today.gz") { | |
171 | + $rotlogfile = $scan_logfile . "-$today.gz"; | |
172 | } elsif (-f "$scan_logfile-$yesterday") { | |
173 | $rotlogfile = $scan_logfile . "-$yesterday"; | |
174 | + } elsif (-f "$scan_logfile-$yesterday.gz") { | |
175 | + $rotlogfile = $scan_logfile . "-$yesterday.gz"; | |
176 | + } else { | |
f90afe04 | 177 | + $rotlogfile = $scan_logfile; |
a87f3b90 | 178 | + # $rotlogfile =~ s/(.*)\/([a-z]*)/$1\/archiv\/$2/g; |
179 | + $rotlogfile =~ s/\/var\/log\/(.*)/\/var\/log\/archive\/$1/g; | |
f90afe04 | 180 | + if ($rotlogfile eq $scan_logfile) { |
181 | + $rotlogfile = "archiv/$scan_logfile"; | |
a87f3b90 | 182 | + } |
183 | + if (-f "$rotlogfile.0") { | |
184 | + $rotlogfile = $rotlogfile . ".0"; | |
185 | + } elsif (-f "$rotlogfile.0.gz") { | |
186 | + $rotlogfile = $rotlogfile . ".0.gz"; | |
187 | + } elsif (-f "$rotlogfile.1") { | |
188 | + $rotlogfile = $rotlogfile . ".1"; | |
189 | + } elsif (-f "$rotlogfile.1.gz") { | |
190 | + $rotlogfile = $rotlogfile . ".1.gz"; | |
191 | + } elsif (-f "$rotlogfile.01") { | |
192 | + $rotlogfile = $rotlogfile . ".01"; | |
193 | + } elsif (-f "$rotlogfile.01.gz") { | |
194 | + $rotlogfile = $rotlogfile . ".01.gz"; | |
195 | + } elsif (-f "$rotlogfile-$today") { | |
196 | + $rotlogfile = $rotlogfile . "-$today"; | |
197 | + } elsif (-f "$rotlogfile-$today.gz") { | |
198 | + $rotlogfile = $rotlogfile . "-$today.gz"; | |
199 | + } elsif (-f "$rotlogfile-$yesterday") { | |
200 | + $rotlogfile = $rotlogfile . "-$yesterday"; | |
201 | + } elsif (-f "$rotlogfile-$yesterday.gz") { | |
202 | + $rotlogfile = $rotlogfile . "-$yesterday.gz"; | |
203 | + } | |
204 | + if (! -f $rotlogfile) { | |
205 | + $rotlogfile = undef; | |
206 | + } | |
207 | } | |
208 | ||
209 | if (defined $rotlogfile) { | |
210 | - parseFile ($rotlogfile, $spos, (stat $rotlogfile)[7]); | |
211 | + if ($rotlogfile =~ /\.gz$/) { | |
212 | + parseFilegz ($rotlogfile, $spos); | |
213 | + } else { | |
214 | + parseFile ($rotlogfile, $spos, (stat $rotlogfile)[7]); | |
215 | + } | |
216 | } else { | |
217 | do_log(1, "ERROR : Could not open rotated logfile."); | |
218 | do_log(1, "ERROR : Tried extentions .0.gz, .0, .1, .01, -$today, -$yesterday"); | |
f90afe04 | 219 | @@ -1803,7 +1895,11 @@ |
a87f3b90 | 220 | } |
044cbf7c | 221 | |
a87f3b90 | 222 | do_log(5, "DEBUG : $scan_logfile, $spos, $eof"); |
223 | - parseFile ($scan_logfile, $spos, $eof); | |
224 | + if ($scan_logfile =~ /\.gz$/) { | |
225 | + parseFilegz ($scan_logfile, $spos); | |
226 | + } else { | |
227 | + parseFile ($scan_logfile, $spos, $eof); | |
228 | + } | |
044cbf7c | 229 | |
a87f3b90 | 230 | saveState(); |
231 | do_log(1, sprintf("Finished -> %s", $scan_domains eq '.*' ? 'localhost' : $scan_domains)); | |
232 | diff -urN amavis-stats-0.1.22.orig/sbin/Makefile.in amavis-stats-0.1.22/sbin/Makefile.in | |
233 | --- amavis-stats-0.1.22.orig/sbin/Makefile.in 2006-12-04 14:00:49.000000000 +0100 | |
f90afe04 | 234 | +++ amavis-stats-0.1.22/sbin/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 235 | @@ -108,7 +108,6 @@ |
236 | GCJ = @GCJ@ | |
237 | GCJFLAGS = @GCJFLAGS@ | |
238 | GETENT = @GETENT@ | |
239 | -GZCAT = @GZCAT@ | |
240 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
241 | LIBTOOL = @LIBTOOL@ | |
242 | LINK_CMD = @LINK_CMD@ | |
243 | diff -urN amavis-stats-0.1.22.orig/share/Makefile.in amavis-stats-0.1.22/share/Makefile.in | |
244 | --- amavis-stats-0.1.22.orig/share/Makefile.in 2006-12-04 14:00:47.000000000 +0100 | |
f90afe04 | 245 | +++ amavis-stats-0.1.22/share/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 246 | @@ -108,7 +108,6 @@ |
247 | GCJ = @GCJ@ | |
248 | GCJFLAGS = @GCJFLAGS@ | |
249 | GETENT = @GETENT@ | |
250 | -GZCAT = @GZCAT@ | |
251 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
252 | LIBTOOL = @LIBTOOL@ | |
253 | LINK_CMD = @LINK_CMD@ | |
254 | diff -urN amavis-stats-0.1.22.orig/startup/Makefile.in amavis-stats-0.1.22/startup/Makefile.in | |
255 | --- amavis-stats-0.1.22.orig/startup/Makefile.in 2006-12-04 14:02:26.000000000 +0100 | |
f90afe04 | 256 | +++ amavis-stats-0.1.22/startup/Makefile.in 2008-05-12 18:28:44.000000000 +0200 |
a87f3b90 | 257 | @@ -108,7 +108,6 @@ |
258 | GCJ = @GCJ@ | |
259 | GCJFLAGS = @GCJFLAGS@ | |
260 | GETENT = @GETENT@ | |
261 | -GZCAT = @GZCAT@ | |
262 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | |
263 | LIBTOOL = @LIBTOOL@ | |
264 | LINK_CMD = @LINK_CMD@ |