1 |
diff -Nur -x '*.orig' -x '*.rej' smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl mezzanine_patched_smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl |
2 |
--- smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl 2007-10-11 16:39:34.000000000 -0400 |
3 |
+++ mezzanine_patched_smeserver-mailstats-0.0.2/root/usr/bin/spamfilter-stats-7.pl 2007-10-11 16:39:19.000000000 -0400 |
4 |
@@ -73,7 +73,8 @@ |
5 |
# - Add in loglevel check |
6 |
# - parameterise email address for report |
7 |
# 0.6.15 - bjr - fix columns included in totals |
8 |
-# - sort out domains when more that one email address in recipient field |
9 |
+# - sort out domains when more that one email address in recipient field |
10 |
+# 0.6.16 - cb - fix date range bug (http://bugs.contribs.org/show_bug.cgi?id=3366) |
11 |
# |
12 |
# TODO |
13 |
# ---- |
14 |
@@ -123,15 +124,10 @@ |
15 |
#Configuration section |
16 |
my %opt = (); |
17 |
|
18 |
-$opt{'version'} = '0.6.15'; # please update at each change. |
19 |
+$opt{'version'} = '0.6.16'; # please update at each change. |
20 |
$opt{'debug'} = 0; # guess what ? |
21 |
$opt{'sendmail'} = '/usr/sbin/sendmail'; # Path to sendmail stub |
22 |
$opt{'from'} = 'spamfilter-stats'; # Who is the mail from |
23 |
-$opt{'end'} = `date --iso-8601`; # midnight today |
24 |
-my $yesterday = $opt{ 'end' }; |
25 |
-$yesterday =~ s/\-//g ; |
26 |
-$yesterday--; |
27 |
-$opt{'start'} = `date --iso-8601 -d $yesterday`; # midnight yesterday |
28 |
#$opt{'mail'} = "admin"; - set from db now... |
29 |
$opt{'timezone'} = `date +%z`; |
30 |
Date_Init("TZ=$opt{'timezone'}"); |
31 |
@@ -143,7 +139,7 @@ |
32 |
my $MAILMAN = "bounces"; #sender when mailman sending when orig is localhost |
33 |
|
34 |
my $MinCol = 8; #Minimum column width |
35 |
-my $HourColWidth = 16; #Date and time column width |
36 |
+my $HourColWidth = 16; #Date and time column width |
37 |
|
38 |
my $SARulethresholdPercent = 10; #If Sa rules less than this of total emails, then cutoff reduced |
39 |
my $maxcutoff = 1; #max percent cutoff applied |
40 |
@@ -176,10 +172,10 @@ |
41 |
my %found_SARules = (); |
42 |
|
43 |
# replaced by... |
44 |
-my %counts = (); #Hold all counts in 2-D matrix |
45 |
-my @display = (); #used to switch on and off columns - yes, no or auto for each category |
46 |
+my %counts = (); #Hold all counts in 2-D matrix |
47 |
+my @display = (); #used to switch on and off columns - yes, no or auto for each category |
48 |
my @colwidth = (); #width of each column |
49 |
- #(auto means only if non zero) - populated from possible db entries |
50 |
+ #(auto means only if non zero) - populated from possible db entries |
51 |
my @finaldisplay = (); #final decision on display or not - true or false |
52 |
my $disabled; |
53 |
|
54 |
@@ -202,7 +198,7 @@ |
55 |
my $CATTOTALS='TOTALS'; |
56 |
my $CATPERCENT='PERCENT'; |
57 |
my @categs = ($CATHOUR,$CATFETCHMAIL,$CATWEBMAIL,$CATMAILMAN,$CATLOCAL,$CATVIRUS,$CATRBLDNS,$CATEXECUT,$CATNONCONF,$CATSPAMDEL,$CATSPAM,$CATHAM,$CATTOTALS,$CATPERCENT); |
58 |
-my $GRANDTOTAL = '99'; #subs for count arrays, for grand total |
59 |
+my $GRANDTOTAL = '99'; #subs for count arrays, for grand total |
60 |
my $PERCENT = '98'; # for column percentages |
61 |
|
62 |
my $categlen = @categs-2; #-2 to avoid the total and percent column |
63 |
@@ -217,7 +213,7 @@ |
64 |
my $warnnoreject = " "; |
65 |
my $rblnotset = ' '; |
66 |
|
67 |
-my $FS = "\t"; # field separator used by logterse plugin |
68 |
+my $FS = "\t"; # field separator used by logterse plugin |
69 |
my %log_items = (); |
70 |
my $score; |
71 |
my %timestamp_items = (); |
72 |
@@ -246,15 +242,15 @@ |
73 |
if ( ( esmith::ConfigDB->open_ro->get('mxbackup')->prop('status') || 'disabled' ) eq 'enabled' ) { |
74 |
my %MXValues = split( /,/, ( esmith::ConfigDB->open_ro->get('mxbackup')->prop('name') || '' ) ) ; |
75 |
foreach my $data ( keys %MXValues ) { |
76 |
- $byrcptdomain{ $data }{ 'type' } = "mxbackup-$MXValues{ $data }" ; |
77 |
+ $byrcptdomain{ $data }{ 'type' } = "mxbackup-$MXValues{ $data }" ; |
78 |
if ( $MXValues{ $data } == 1 ) { # subdomains allowed, must take care of this |
79 |
- push @extdomain, $data ; |
80 |
+ push @extdomain, $data ; |
81 |
} |
82 |
} |
83 |
} |
84 |
} |
85 |
|
86 |
-my ( $start, $end ) = parse_arg( $opt{'start'}, $opt{'end'} ); |
87 |
+my ( $start, $end ) = parse_arg(); |
88 |
|
89 |
# |
90 |
# First check current configuration for logging, DNS enable and Max threshold for spamassassin |
91 |
@@ -309,13 +305,13 @@ |
92 |
my $nhour = floor( $start / 3600 ); |
93 |
my $ncateg; |
94 |
while ( $nhour < $end / 3600 ) { |
95 |
- $counts{$nhour}=(); |
96 |
+ $counts{$nhour}=(); |
97 |
$ncateg = 0; |
98 |
- while ( $ncateg < @categs) { |
99 |
- $counts{$nhour}{$categs[$ncateg-1]} = 0; |
100 |
- $ncateg++ |
101 |
- } |
102 |
- $nhour++; |
103 |
+ while ( $ncateg < @categs) { |
104 |
+ $counts{$nhour}{$categs[$ncateg-1]} = 0; |
105 |
+ $ncateg++ |
106 |
+ } |
107 |
+ $nhour++; |
108 |
} |
109 |
# and grand totals and display status from db entries, and column widths |
110 |
$ncateg = 0; |
111 |
@@ -374,11 +370,11 @@ |
112 |
# we store the more recent recipient domain, for domain statistics |
113 |
# in fact, we only store the first recipient. Could be sort of headhache |
114 |
# to obtain precise stats with many recipients on more than one domain ! |
115 |
- my $proc = $timestamp_items[1] ; #numeric Id for the email |
116 |
+ my $proc = $timestamp_items[1] ; #numeric Id for the email |
117 |
|
118 |
- $totalexamined++; |
119 |
+ $totalexamined++; |
120 |
|
121 |
- # first spot the fetchmail and local deliveries. |
122 |
+ # first spot the fetchmail and local deliveries. |
123 |
|
124 |
# print '<'.$log_items[1].'><'.$log_items[5].'><'.$log_items[8].">\n"; |
125 |
|
126 |
@@ -411,54 +407,54 @@ |
127 |
# and adjust for recipient field if not set-up by denying plugin - extract from deny msg |
128 |
|
129 |
if (length($log_items[4])==0) { |
130 |
- if ($log_items[5] eq 'check_goodrcptto') { |
131 |
- if ($log_items[7] gt "invalid recipient") { |
132 |
- $log_items[4] = substr($log_items[7],18) #Leave only email address |
133 |
- } |
134 |
- } |
135 |
- } |
136 |
- |
137 |
- if ( ( $currentrcptdomain{ $proc } || '' ) eq '' ) { |
138 |
- # reduce to lc and only take first email address in a list |
139 |
- my $recipientmail = lc($log_items[4]); |
140 |
- if ($recipientmail =~ m/.*,/) { |
141 |
- #comma |
142 |
- $recipientmail =~ m/(.*),/; |
143 |
- $currentrcptdomain{ $proc } = $1; |
144 |
- } else { |
145 |
- $currentrcptdomain{ $proc } = lc($log_items[4]) |
146 |
- } |
147 |
- #split to just domain bit. |
148 |
- $currentrcptdomain{ $proc } =~ s/.*@//; |
149 |
- $currentrcptdomain{ $proc } =~ s/[^\w\-\.]//g ; |
150 |
- $currentrcptdomain{ $proc } =~ s/>//g ; |
151 |
- |
152 |
-# print $currentrcptdomain{ $proc }."\n"; |
153 |
- |
154 |
- my $NotableDomain = 0 ; |
155 |
- if ( defined ( $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'type' } ) ) { |
156 |
- $NotableDomain = 1 ; |
157 |
- } else { |
158 |
- foreach ( @extdomain ) { |
159 |
- if ( $currentrcptdomain{ $proc } =~ m/$_$/ ) { |
160 |
- $NotableDomain = 1 ; |
161 |
- last ; |
162 |
- } |
163 |
- } |
164 |
- } |
165 |
- if ( !$NotableDomain ) { |
166 |
- # check for outgoing email |
167 |
- if ($localflag==1) {$currentrcptdomain{ $proc } = 'Outgoing'} |
168 |
- else {$currentrcptdomain{ $proc } = 'Others'} |
169 |
- } else { |
170 |
- if ($localflag==1) {$currentrcptdomain{ $proc } = 'Internal'} |
171 |
- } |
172 |
- $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'total' }++ ; |
173 |
- } else { |
174 |
- # there more than a recipient for a mail, how many daily ? |
175 |
- $morethanonercpt++; |
176 |
- } |
177 |
- |
178 |
+ if ($log_items[5] eq 'check_goodrcptto') { |
179 |
+ if ($log_items[7] gt "invalid recipient") { |
180 |
+ $log_items[4] = substr($log_items[7],18) #Leave only email address |
181 |
+ } |
182 |
+ } |
183 |
+ } |
184 |
+ |
185 |
+ if ( ( $currentrcptdomain{ $proc } || '' ) eq '' ) { |
186 |
+ # reduce to lc and only take first email address in a list |
187 |
+ my $recipientmail = lc($log_items[4]); |
188 |
+ if ($recipientmail =~ m/.*,/) { |
189 |
+ #comma |
190 |
+ $recipientmail =~ m/(.*),/; |
191 |
+ $currentrcptdomain{ $proc } = $1; |
192 |
+ } else { |
193 |
+ $currentrcptdomain{ $proc } = lc($log_items[4]) |
194 |
+ } |
195 |
+ #split to just domain bit. |
196 |
+ $currentrcptdomain{ $proc } =~ s/.*@//; |
197 |
+ $currentrcptdomain{ $proc } =~ s/[^\w\-\.]//g ; |
198 |
+ $currentrcptdomain{ $proc } =~ s/>//g ; |
199 |
+ |
200 |
+# print $currentrcptdomain{ $proc }."\n"; |
201 |
+ |
202 |
+ my $NotableDomain = 0 ; |
203 |
+ if ( defined ( $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'type' } ) ) { |
204 |
+ $NotableDomain = 1 ; |
205 |
+ } else { |
206 |
+ foreach ( @extdomain ) { |
207 |
+ if ( $currentrcptdomain{ $proc } =~ m/$_$/ ) { |
208 |
+ $NotableDomain = 1 ; |
209 |
+ last ; |
210 |
+ } |
211 |
+ } |
212 |
+ } |
213 |
+ if ( !$NotableDomain ) { |
214 |
+ # check for outgoing email |
215 |
+ if ($localflag==1) {$currentrcptdomain{ $proc } = 'Outgoing'} |
216 |
+ else {$currentrcptdomain{ $proc } = 'Others'} |
217 |
+ } else { |
218 |
+ if ($localflag==1) {$currentrcptdomain{ $proc } = 'Internal'} |
219 |
+ } |
220 |
+ $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'total' }++ ; |
221 |
+ } else { |
222 |
+ # there more than a recipient for a mail, how many daily ? |
223 |
+ $morethanonercpt++; |
224 |
+ } |
225 |
+ |
226 |
# then categorise the result |
227 |
|
228 |
|
229 |
@@ -532,8 +528,8 @@ |
230 |
$hamcount++;$counts{$abshour}{$CATHAM}++; |
231 |
} |
232 |
if ( ( $currentrcptdomain{ $proc } || '' ) ne '' ) { |
233 |
- $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'accept' }++ ; |
234 |
- $currentrcptdomain{ $proc } = '' ; |
235 |
+ $byrcptdomain{ $currentrcptdomain{ $proc } }{ 'accept' }++ ; |
236 |
+ $currentrcptdomain{ $proc } = '' ; |
237 |
} |
238 |
next LINE |
239 |
} |
240 |
@@ -547,20 +543,20 @@ |
241 |
#total up grand total Columns |
242 |
$nhour = floor( $start / 3600 ); |
243 |
while ( $nhour < $end / 3600 ) { |
244 |
- $ncateg = 0; #past the where it came from columns |
245 |
- while ( $ncateg < @categs) { |
246 |
- #total columns |
247 |
- $counts{$GRANDTOTAL}{$categs[$ncateg]} += $counts{$nhour}{$categs[$ncateg]}; |
248 |
+ $ncateg = 0; #past the where it came from columns |
249 |
+ while ( $ncateg < @categs) { |
250 |
+ #total columns |
251 |
+ $counts{$GRANDTOTAL}{$categs[$ncateg]} += $counts{$nhour}{$categs[$ncateg]}; |
252 |
|
253 |
# and total rows |
254 |
if ( $ncateg < $categlen && $ncateg>=$countfromhere) {#skip initial columns of non final reasons |
255 |
$counts{$nhour}{$categs[@categs-2]} += $counts{$nhour}{$categs[$ncateg]}; |
256 |
} |
257 |
- $ncateg++ |
258 |
- } |
259 |
- |
260 |
- $nhour++; |
261 |
-} |
262 |
+ $ncateg++ |
263 |
+ } |
264 |
+ |
265 |
+ $nhour++; |
266 |
+} |
267 |
|
268 |
|
269 |
|
270 |
@@ -573,15 +569,15 @@ |
271 |
} |
272 |
|
273 |
#compute column percentages |
274 |
- $ncateg = 0; |
275 |
- while ( $ncateg < @categs) { |
276 |
- if ($ncateg == @categs-1) { |
277 |
- $counts{$PERCENT}{$categs[$ncateg]} = $counts{$GRANDTOTAL}{$categs[$ncateg-1]}*100/$totalexamined if $totalexamined; |
278 |
- } else { |
279 |
- $counts{$PERCENT}{$categs[$ncateg]} = $counts{$GRANDTOTAL}{$categs[$ncateg]}*100/$totalexamined if $totalexamined; |
280 |
+ $ncateg = 0; |
281 |
+ while ( $ncateg < @categs) { |
282 |
+ if ($ncateg == @categs-1) { |
283 |
+ $counts{$PERCENT}{$categs[$ncateg]} = $counts{$GRANDTOTAL}{$categs[$ncateg-1]}*100/$totalexamined if $totalexamined; |
284 |
+ } else { |
285 |
+ $counts{$PERCENT}{$categs[$ncateg]} = $counts{$GRANDTOTAL}{$categs[$ncateg]}*100/$totalexamined if $totalexamined; |
286 |
} |
287 |
- $ncateg++ |
288 |
- } |
289 |
+ $ncateg++ |
290 |
+ } |
291 |
|
292 |
#compute sum of row percentages |
293 |
$nhour = floor( $start / 3600 ); |
294 |
@@ -657,7 +653,7 @@ |
295 |
print "----------------------------\n"; |
296 |
print "\n"; |
297 |
|
298 |
- printf "All SMTP connections accepted:%8d \n", $totalexamined; |
299 |
+ printf "All SMTP connections accepted:%8d \n", $totalexamined; |
300 |
# |
301 |
# if ($localAccepttotal>0) { |
302 |
# printf "Connections from Fetchmail : %8d \n", |
303 |
@@ -666,13 +662,13 @@ |
304 |
# |
305 |
# if ($WebMailsendtotal>0) { |
306 |
# printf "Emails sent from WebMail : %8d \n", |
307 |
-# $WebMailsendtotal; |
308 |
+# $WebMailsendtotal; |
309 |
# } |
310 |
# |
311 |
# if ($mailmansendcount > 0) { |
312 |
# printf "Emails sent from Mailman : %8d \n", |
313 |
-# $mailmansendcount; |
314 |
-# } |
315 |
+# $mailmansendcount; |
316 |
+# } |
317 |
# |
318 |
# printf "SMTP from local workstations : %8d \n\n", $localsendtotal; |
319 |
# |
320 |
@@ -706,12 +702,12 @@ |
321 |
print "\n"; |
322 |
print "Statistics by Hour\n"; |
323 |
|
324 |
- # |
325 |
- # start by working out which colunns to show - tag the display array |
326 |
- # |
327 |
- $ncateg = 1; ##skip the first column |
328 |
- $finaldisplay[0] = $true; |
329 |
- while ( $ncateg < $categlen) { |
330 |
+ # |
331 |
+ # start by working out which colunns to show - tag the display array |
332 |
+ # |
333 |
+ $ncateg = 1; ##skip the first column |
334 |
+ $finaldisplay[0] = $true; |
335 |
+ while ( $ncateg < $categlen) { |
336 |
if ($display[$ncateg] eq 'yes') { $finaldisplay[$ncateg] = $true } |
337 |
elsif ($display[$ncateg] eq 'no') { $finaldisplay[$ncateg] = $false } |
338 |
else { |
339 |
@@ -722,77 +718,77 @@ |
340 |
} |
341 |
|
342 |
} |
343 |
- $ncateg++ |
344 |
- } |
345 |
+ $ncateg++ |
346 |
+ } |
347 |
#make sure total and percentages are shown |
348 |
$finaldisplay[@categs-2] = $true; |
349 |
$finaldisplay[@categs-1] = $true; |
350 |
- |
351 |
+ |
352 |
|
353 |
# and put together the print lines |
354 |
# |
355 |
- my $Line1; #Full Line across the page |
356 |
- my $Line2; #Broken Line across the page |
357 |
- my $Titles; #Column headers |
358 |
- my $Values; #Values |
359 |
- my $Totals; #Corresponding totals |
360 |
+ my $Line1; #Full Line across the page |
361 |
+ my $Line2; #Broken Line across the page |
362 |
+ my $Titles; #Column headers |
363 |
+ my $Values; #Values |
364 |
+ my $Totals; #Corresponding totals |
365 |
my $Percent; # and column percentages |
366 |
|
367 |
my $hour = floor( $start / 3600 ); |
368 |
- $Line1 = ''; |
369 |
- $Line2 = ''; |
370 |
- $Titles = ''; |
371 |
- $Values = ''; |
372 |
- $Totals = ''; |
373 |
- $Percent = ''; |
374 |
+ $Line1 = ''; |
375 |
+ $Line2 = ''; |
376 |
+ $Titles = ''; |
377 |
+ $Values = ''; |
378 |
+ $Totals = ''; |
379 |
+ $Percent = ''; |
380 |
while ( $hour < $end / 3600 ) { |
381 |
- if ($hour == floor( $start / 3600 )){ |
382 |
- #Do all the once only things |
383 |
- $ncateg = 0; |
384 |
- while ( $ncateg < @categs) { |
385 |
+ if ($hour == floor( $start / 3600 )){ |
386 |
+ #Do all the once only things |
387 |
+ $ncateg = 0; |
388 |
+ while ( $ncateg < @categs) { |
389 |
if ($finaldisplay[$ncateg]){ |
390 |
- $Line1 .= substr('---------------------',0,$colwidth[$ncateg]); |
391 |
- $Line2 .= substr('---------------------',0,$colwidth[$ncateg]-1); |
392 |
- $Line2 .= " "; |
393 |
- $Titles .= sprintf('%'.($colwidth[$ncateg]-1).'s',$categs[$ncateg])." "; |
394 |
+ $Line1 .= substr('---------------------',0,$colwidth[$ncateg]); |
395 |
+ $Line2 .= substr('---------------------',0,$colwidth[$ncateg]-1); |
396 |
+ $Line2 .= " "; |
397 |
+ $Titles .= sprintf('%'.($colwidth[$ncateg]-1).'s',$categs[$ncateg])." "; |
398 |
if ($ncateg == 0) { |
399 |
$Totals .= substr('TOTALS ',0,$colwidth[$ncateg]-2); |
400 |
$Percent .= substr('PERCENTAGES ',0,$colwidth[$ncateg]-1); |
401 |
} else { |
402 |
# identify bottom right group and supress unless db->ShowGranPerc set |
403 |
if ($ncateg==@categs-1){ |
404 |
- $Totals .= sprintf('%'.$colwidth[$ncateg].'.1f',$counts{$GRANDTOTAL}{$categs[$ncateg]}).'%'; |
405 |
- } else { |
406 |
- $Totals .= sprintf('%'.$colwidth[$ncateg].'d',$counts{$GRANDTOTAL}{$categs[$ncateg]}); |
407 |
- } |
408 |
- $Percent .= sprintf('%'.($colwidth[$ncateg]-1).'.1f',$counts{$PERCENT}{$categs[$ncateg]}).'%'; |
409 |
- } |
410 |
+ $Totals .= sprintf('%'.$colwidth[$ncateg].'.1f',$counts{$GRANDTOTAL}{$categs[$ncateg]}).'%'; |
411 |
+ } else { |
412 |
+ $Totals .= sprintf('%'.$colwidth[$ncateg].'d',$counts{$GRANDTOTAL}{$categs[$ncateg]}); |
413 |
+ } |
414 |
+ $Percent .= sprintf('%'.($colwidth[$ncateg]-1).'.1f',$counts{$PERCENT}{$categs[$ncateg]}).'%'; |
415 |
+ } |
416 |
} |
417 |
- $ncateg++ |
418 |
- } |
419 |
- } |
420 |
- |
421 |
- $ncateg = 0; |
422 |
- while ( $ncateg < @categs) { |
423 |
- if ($finaldisplay[$ncateg]){ |
424 |
- if ($ncateg == 0) { |
425 |
- $Values .= strftime( "%F, %H", localtime( $hour * 3600 ) )." " |
426 |
- } elsif ($ncateg == @categs-1) { |
427 |
- #percentages in last column |
428 |
- $Values .= sprintf('%'.($colwidth[$ncateg]-2).'.1f',$counts{$hour}{$categs[$ncateg]})."%"; |
429 |
- } else { |
430 |
- #body numbers |
431 |
- $Values .= sprintf('%'.($colwidth[$ncateg]-1).'d',$counts{$hour}{$categs[$ncateg]})." "; |
432 |
- } |
433 |
- if (($ncateg == @categs-1)){$Values=$Values."\n"} #&& ($hour == floor($end / 3600)-1) |
434 |
- } |
435 |
- $ncateg++ |
436 |
- } |
437 |
- |
438 |
- $hour++; |
439 |
- } |
440 |
+ $ncateg++ |
441 |
+ } |
442 |
+ } |
443 |
|
444 |
- # print it. |
445 |
+ $ncateg = 0; |
446 |
+ while ( $ncateg < @categs) { |
447 |
+ if ($finaldisplay[$ncateg]){ |
448 |
+ if ($ncateg == 0) { |
449 |
+ $Values .= strftime( "%F, %H", localtime( $hour * 3600 ) )." " |
450 |
+ } elsif ($ncateg == @categs-1) { |
451 |
+ #percentages in last column |
452 |
+ $Values .= sprintf('%'.($colwidth[$ncateg]-2).'.1f',$counts{$hour}{$categs[$ncateg]})."%"; |
453 |
+ } else { |
454 |
+ #body numbers |
455 |
+ $Values .= sprintf('%'.($colwidth[$ncateg]-1).'d',$counts{$hour}{$categs[$ncateg]})." "; |
456 |
+ } |
457 |
+ if (($ncateg == @categs-1)){$Values=$Values."\n"} #&& ($hour == floor($end / 3600)-1) |
458 |
+ } |
459 |
+ $ncateg++ |
460 |
+ } |
461 |
+ |
462 |
+ $hour++; |
463 |
+ } |
464 |
+ |
465 |
+ # print it. |
466 |
print $Line1."\n"; |
467 |
print $Titles."\n"; |
468 |
print $Line2."\n"; |
469 |
@@ -906,24 +902,24 @@ |
470 |
} |
471 |
|
472 |
# get enable/disable subsections |
473 |
- my $enableqpsmtpdcodes; |
474 |
- my $enableSARules; |
475 |
- my $enablejunkMailList; |
476 |
+ my $enableqpsmtpdcodes; |
477 |
+ my $enableSARules; |
478 |
+ my $enablejunkMailList; |
479 |
if (esmith::ConfigDB->open_ro->get('mailstats')){ |
480 |
- $enableqpsmtpdcodes = esmith::ConfigDB->open_ro->get('mailstats')->prop("QpsmtpdCodes") || "enabled" eq "enabled" || $true; |
481 |
- $enableSARules = esmith::ConfigDB->open_ro->get('mailstats')->prop("SARules") || "enabled" eq "enabled" || $true; |
482 |
- $enablejunkMailList = esmith::ConfigDB->open_ro->get('mailstats')->prop("JunkMailList") || "enabled" eq "enabled" || $true; |
483 |
- } else { |
484 |
- $enableqpsmtpdcodes = $true; |
485 |
- $enableSARules = $true; |
486 |
- $enablejunkMailList = $true; |
487 |
- } |
488 |
+ $enableqpsmtpdcodes = esmith::ConfigDB->open_ro->get('mailstats')->prop("QpsmtpdCodes") || "enabled" eq "enabled" || $true; |
489 |
+ $enableSARules = esmith::ConfigDB->open_ro->get('mailstats')->prop("SARules") || "enabled" eq "enabled" || $true; |
490 |
+ $enablejunkMailList = esmith::ConfigDB->open_ro->get('mailstats')->prop("JunkMailList") || "enabled" eq "enabled" || $true; |
491 |
+ } else { |
492 |
+ $enableqpsmtpdcodes = $true; |
493 |
+ $enableSARules = $true; |
494 |
+ $enablejunkMailList = $true; |
495 |
+ } |
496 |
|
497 |
if ($enableqpsmtpdcodes) {show_qpsmtpd_codes();} |
498 |
|
499 |
if ($enableSARules) {show_SARules_codes();} |
500 |
|
501 |
- if ($enablejunkMailList) {List_Junkmail();} |
502 |
+ if ($enablejunkMailList) {List_Junkmail();} |
503 |
|
504 |
print "\nDone. Report generated in $telapsed sec.\n\n"; |
505 |
|
506 |
@@ -997,25 +993,25 @@ |
507 |
my $adb = esmith::AccountsDB->open_ro; |
508 |
my $entry; |
509 |
foreach my $user ($adb->users) { |
510 |
- my $found = 0; |
511 |
- my $junkmail_dir = "/home/e-smith/files/users/" . |
512 |
- $user->key . "/Maildir/.junkmail"; |
513 |
+ my $found = 0; |
514 |
+ my $junkmail_dir = "/home/e-smith/files/users/" . |
515 |
+ $user->key . "/Maildir/.junkmail"; |
516 |
# print $user->key; |
517 |
- foreach my $dir (qw(new cur)) { |
518 |
+ foreach my $dir (qw(new cur)) { |
519 |
# Now get the content list for the directory. |
520 |
if (opendir( QDIR, "$junkmail_dir/$dir" )) { |
521 |
- while ($entry=readdir(QDIR) ) { |
522 |
- next if $entry =~ /^\./; |
523 |
- $found++; |
524 |
- } |
525 |
- |
526 |
- closedir(QDIR); |
527 |
- } |
528 |
- } |
529 |
- if ( !$disabled ) { |
530 |
- printf "User \"%s\" ", $user->key; |
531 |
- printf "- %d email(s) left in junkmail folder\n", $found; |
532 |
- } |
533 |
+ while ($entry=readdir(QDIR) ) { |
534 |
+ next if $entry =~ /^\./; |
535 |
+ $found++; |
536 |
+ } |
537 |
+ |
538 |
+ closedir(QDIR); |
539 |
+ } |
540 |
+ } |
541 |
+ if ( !$disabled ) { |
542 |
+ printf "User \"%s\" ", $user->key; |
543 |
+ printf "- %d email(s) left in junkmail folder\n", $found; |
544 |
+ } |
545 |
} |
546 |
} |
547 |
|
548 |
@@ -1030,9 +1026,9 @@ |
549 |
print("Virus Statistics by name:\n"); |
550 |
print("---------------------------------------------\n"); |
551 |
foreach my $virus (sort { $found_viruses{$b} <=> $found_viruses{$a} } |
552 |
- keys %found_viruses) |
553 |
+ keys %found_viruses) |
554 |
{ |
555 |
- print "Rejected $found_viruses{$virus}\t$virus\n"; |
556 |
+ print "Rejected $found_viruses{$virus}\t$virus\n"; |
557 |
} |
558 |
print("---------------------------------------------\n\n"); |
559 |
} |
560 |
@@ -1050,9 +1046,9 @@ |
561 |
print("Count\tPercent\tReason\t\n"); |
562 |
print("---------------------------------------------\n"); |
563 |
foreach my $qpcode (sort { $found_qpcodes{$b} <=> $found_qpcodes{$a} } |
564 |
- keys %found_qpcodes) |
565 |
+ keys %found_qpcodes) |
566 |
{ |
567 |
- print "$found_qpcodes{$qpcode}\t".sprintf('%4.1f',$found_qpcodes{$qpcode}*100/$totalexamined)."%\t$qpcode\n" if $totalexamined; |
568 |
+ print "$found_qpcodes{$qpcode}\t".sprintf('%4.1f',$found_qpcodes{$qpcode}*100/$totalexamined)."%\t$qpcode\n" if $totalexamined; |
569 |
} |
570 |
print("---------------------------------------------\n\n"); |
571 |
} |
572 |
@@ -1075,21 +1071,21 @@ |
573 |
$defaultpercentthreshold = $mincutoff |
574 |
} |
575 |
if (esmith::ConfigDB->open_ro->get('mailstats')){ |
576 |
- $percentthreshold = esmith::ConfigDB->open_ro->get('mailstats')->prop("SARulePercentThreshold") || $defaultpercentthreshold; |
577 |
- } else { |
578 |
- $percentthreshold = $defaultpercentthreshold |
579 |
- } |
580 |
+ $percentthreshold = esmith::ConfigDB->open_ro->get('mailstats')->prop("SARulePercentThreshold") || $defaultpercentthreshold; |
581 |
+ } else { |
582 |
+ $percentthreshold = $defaultpercentthreshold |
583 |
+ } |
584 |
print("Spamassassin Rules:\n"); |
585 |
print("---------------------------------------------\n"); |
586 |
print("Count\tPercent\tRule\t\n"); |
587 |
print("---------------------------------------------\n"); |
588 |
foreach my $SARule (sort { $found_SARules{$b} <=> $found_SARules{$a} } |
589 |
- keys %found_SARules) |
590 |
+ keys %found_SARules) |
591 |
{ |
592 |
- my $percent = $found_SARules{$SARule}*100/$totalexamined if $totalexamined; |
593 |
- if ($percent > $percentthreshold) { |
594 |
- print "$found_SARules{$SARule}\t".sprintf('%4.1f',$percent)."%\t$SARule\n" if $totalexamined; |
595 |
- } |
596 |
+ my $percent = $found_SARules{$SARule}*100/$totalexamined if $totalexamined; |
597 |
+ if ($percent > $percentthreshold) { |
598 |
+ print "$found_SARules{$SARule}\t".sprintf('%4.1f',$percent)."%\t$SARule\n" if $totalexamined; |
599 |
+ } |
600 |
} |
601 |
print("---------------------------------------------\n\n"); |
602 |
} |
603 |
@@ -1106,4 +1102,4 @@ |
604 |
$byrcptdomain{ $currentrcptdomain{ $proc } }{ 'deny' }++ ; |
605 |
$currentrcptdomain{ $proc } = '' ; |
606 |
} |
607 |
-} |
608 |
\ No newline at end of file |
609 |
+} |