]> git.pld-linux.org Git - packages/amavis-stats.git/blob - amavis-stats-gzip.patch
- sed 4.0 not just sed
[packages/amavis-stats.git] / amavis-stats-gzip.patch
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
3 +++ amavis-stats-0.1.22/configure.in    2008-05-12 14:38:27.000000000 +0200
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 @@
13  
14  PERL_VERSION=`$PERL -MConfig -e 'print $Config{version}'`
15  
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([
26  
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
29 +++ amavis-stats-0.1.22/doc/Makefile.in 2008-05-12 14:38:27.000000000 +0200
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
40 +++ amavis-stats-0.1.22/etc/Makefile.in 2008-05-12 14:38:27.000000000 +0200
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
51 +++ amavis-stats-0.1.22/Makefile.in     2008-05-12 14:38:27.000000000 +0200
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
62 +++ amavis-stats-0.1.22/php/Makefile.in 2008-05-12 14:38:27.000000000 +0200
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
73 +++ amavis-stats-0.1.22/sbin/amavis-stats.in    2008-05-12 14:38:57.000000000 +0200
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  }
81  
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);
90 @@ -1596,6 +1598,55 @@
91  
92         }
93  
94 +       sub parseFilegz {
95 +
96 +               my ($fname, $start) = @_;
97 +               do_log(2, "parseFilegz($fname, $start)");
98 +
99 +               #
100 +               # Open up the file we need to parse
101 +               #
102 +               unless (my $gz = gzopen ($fname, "rb") {
103 +                       do_log(1, "ERROR : Could not open file $fname: $!"); 
104 +               }
105 +
106 +               #
107 +               # Loop each line until the current end of file
108 +               #
109 +               $pos = 0;
110 +               while ($pos < $start) {
111 +                       $pos += $gz->gzreadline($line);
112 +               }
113 +
114 +               my $lineid = 0;
115 +               my $p = 0;
116 +
117 +               do {
118 +                       $p = $gz->gzreadline($line);
119 +                       $pos += $p;
120 +
121 +                       if ($p > 0) {
122 +                               $lineid++;
123 +                               $lastepoch = $epoch;
124 +
125 +                               if ($line =~ /amavis.*?\[\d+\]:/) {
126 +                                       classify();
127 +                               }
128 +
129 +                               #
130 +                               # Save the current statistics every 1000 lines. This way
131 +                               # if the program dies we don't have to start again from the 
132 +                               # beginning each time. Also good for monitoring the graphs
133 +                               # to see where we are up to.
134 +                               #
135 +                               if (!($lineid % 1000)) {
136 +                                       saveState();;
137 +                               }
138 +                       }
139 +               } while $p > 0;
140 +               $gz->gzclose();
141 +       }
142 +
143         sub parseRotFile { 
144                 do_log(5, "DEBUG : parseRotFile()");
145                 my ($scan_logfile, $spos) = @_;
146 @@ -1614,25 +1665,65 @@
147  
148                 my $rotlogfile = undef;
149  
150 -               if (! -f "$scan_logfile.0" && -f "$scan_logfile.0.gz" ) {
151 -                       do_log(2 , "copying $scan_logfile.0.gz -> $scan_logfile.0");
152 -                       `gzcat "$scan_logfile.0.gz" > "$scan_logfile.0"`;
153 -               }
154 -               
155                 if (-f "$scan_logfile.0") {
156                         $rotlogfile = $scan_logfile . ".0";
157 +               } elsif (-f "$scan_logfile.0.gz") {
158 +                       $rotlogfile = $scan_logfile . ".0.gz";
159                 } elsif (-f "$scan_logfile.1") {
160                         $rotlogfile = $scan_logfile . ".1";
161 +               } elsif (-f "$scan_logfile.1.gz") {
162 +                       $rotlogfile = $scan_logfile . ".1.gz";
163                 } elsif (-f "$scan_logfile.01") {
164                         $rotlogfile = $scan_logfile . ".01";
165 +               } elsif (-f "$scan_logfile.01.gz") {
166 +                       $rotlogfile = $scan_logfile . ".01.gz";
167                 } elsif (-f "$scan_logfile-$today") {
168                         $rotlogfile = $scan_logfile . "-$today";
169 +               } elsif (-f "$scan_logfile-$today.gz") {
170 +                       $rotlogfile = $scan_logfile . "-$today.gz";
171                 } elsif (-f "$scan_logfile-$yesterday") {
172                         $rotlogfile = $scan_logfile . "-$yesterday";
173 +               } elsif (-f "$scan_logfile-$yesterday.gz") {
174 +                       $rotlogfile = $scan_logfile . "-$yesterday.gz";
175 +               } else {
176 +                       $rotlogfile = $logfile;
177 +                       # $rotlogfile =~ s/(.*)\/([a-z]*)/$1\/archiv\/$2/g;
178 +                       $rotlogfile =~ s/\/var\/log\/(.*)/\/var\/log\/archive\/$1/g;
179 +                       if ($rotlogfile eq $logfile) {
180 +                               $rotlogfile = "archiv/$logfile";
181 +                       }
182 +                       if (-f "$rotlogfile.0") {
183 +                               $rotlogfile = $rotlogfile . ".0";
184 +                       } elsif (-f "$rotlogfile.0.gz") {
185 +                               $rotlogfile = $rotlogfile . ".0.gz";
186 +                       } elsif (-f "$rotlogfile.1") {
187 +                               $rotlogfile = $rotlogfile . ".1";
188 +                       } elsif (-f "$rotlogfile.1.gz") {
189 +                               $rotlogfile = $rotlogfile . ".1.gz";
190 +                       } elsif (-f "$rotlogfile.01") {
191 +                               $rotlogfile = $rotlogfile . ".01";
192 +                       } elsif (-f "$rotlogfile.01.gz") {
193 +                               $rotlogfile = $rotlogfile . ".01.gz";
194 +                       } elsif (-f "$rotlogfile-$today") {
195 +                               $rotlogfile = $rotlogfile . "-$today";
196 +                       } elsif (-f "$rotlogfile-$today.gz") {
197 +                               $rotlogfile = $rotlogfile . "-$today.gz";
198 +                       } elsif (-f "$rotlogfile-$yesterday") {
199 +                               $rotlogfile = $rotlogfile . "-$yesterday";
200 +                       } elsif (-f "$rotlogfile-$yesterday.gz") {
201 +                               $rotlogfile = $rotlogfile . "-$yesterday.gz";
202 +                       }
203 +                       if (! -f $rotlogfile) {
204 +                               $rotlogfile = undef;
205 +                       }
206                 }
207  
208                 if (defined $rotlogfile) {
209 -                       parseFile ($rotlogfile, $spos, (stat $rotlogfile)[7]);
210 +                       if ($rotlogfile =~ /\.gz$/) {
211 +                               parseFilegz ($rotlogfile, $spos);
212 +                       } else {
213 +                               parseFile ($rotlogfile, $spos, (stat $rotlogfile)[7]);
214 +                       }
215                 } else {
216                         do_log(1, "ERROR : Could not open rotated logfile.");
217                         do_log(1, "ERROR :      Tried extentions .0.gz, .0, .1, .01, -$today, -$yesterday");
218 @@ -1803,7 +1894,11 @@
219                         }
220  
221                         do_log(5, "DEBUG : $scan_logfile, $spos, $eof");
222 -                       parseFile ($scan_logfile, $spos, $eof);
223 +                       if ($scan_logfile =~ /\.gz$/) {
224 +                               parseFilegz ($scan_logfile, $spos);
225 +                       } else {
226 +                               parseFile ($scan_logfile, $spos, $eof);
227 +                       }
228  
229                         saveState();
230                         do_log(1, sprintf("Finished -> %s", $scan_domains eq '.*' ? 'localhost' : $scan_domains));
231 diff -urN amavis-stats-0.1.22.orig/sbin/Makefile.in amavis-stats-0.1.22/sbin/Makefile.in
232 --- amavis-stats-0.1.22.orig/sbin/Makefile.in   2006-12-04 14:00:49.000000000 +0100
233 +++ amavis-stats-0.1.22/sbin/Makefile.in        2008-05-12 14:38:27.000000000 +0200
234 @@ -108,7 +108,6 @@
235  GCJ = @GCJ@
236  GCJFLAGS = @GCJFLAGS@
237  GETENT = @GETENT@
238 -GZCAT = @GZCAT@
239  INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
240  LIBTOOL = @LIBTOOL@
241  LINK_CMD = @LINK_CMD@
242 diff -urN amavis-stats-0.1.22.orig/share/Makefile.in amavis-stats-0.1.22/share/Makefile.in
243 --- amavis-stats-0.1.22.orig/share/Makefile.in  2006-12-04 14:00:47.000000000 +0100
244 +++ amavis-stats-0.1.22/share/Makefile.in       2008-05-12 14:38:27.000000000 +0200
245 @@ -108,7 +108,6 @@
246  GCJ = @GCJ@
247  GCJFLAGS = @GCJFLAGS@
248  GETENT = @GETENT@
249 -GZCAT = @GZCAT@
250  INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
251  LIBTOOL = @LIBTOOL@
252  LINK_CMD = @LINK_CMD@
253 diff -urN amavis-stats-0.1.22.orig/startup/Makefile.in amavis-stats-0.1.22/startup/Makefile.in
254 --- amavis-stats-0.1.22.orig/startup/Makefile.in        2006-12-04 14:02:26.000000000 +0100
255 +++ amavis-stats-0.1.22/startup/Makefile.in     2008-05-12 14:38:27.000000000 +0200
256 @@ -108,7 +108,6 @@
257  GCJ = @GCJ@
258  GCJFLAGS = @GCJFLAGS@
259  GETENT = @GETENT@
260 -GZCAT = @GZCAT@
261  INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
262  LIBTOOL = @LIBTOOL@
263  LINK_CMD = @LINK_CMD@
This page took 1.003167 seconds and 4 git commands to generate.