You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2008/02/05 05:55:39 UTC
svn commit: r618539 - /spamassassin/trunk/masses/log-grep-recent
Author: dos
Date: Mon Feb 4 20:55:38 2008
New Revision: 618539
URL: http://svn.apache.org/viewvc?rev=618539&view=rev
Log:
add --set option to log-grep-recent so that we can select set=1 messages from nightly runs with reuse=yes; do it in log-grep-recent so that we don't have to grep multiple GB of log files more than necessary (one time through chews enough disk i/o)
Modified:
spamassassin/trunk/masses/log-grep-recent
Modified: spamassassin/trunk/masses/log-grep-recent
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/log-grep-recent?rev=618539&r1=618538&r2=618539&view=diff
==============================================================================
--- spamassassin/trunk/masses/log-grep-recent (original)
+++ spamassassin/trunk/masses/log-grep-recent Mon Feb 4 20:55:38 2008
@@ -1,11 +1,12 @@
#!/usr/bin/perl
#
# log-grep-recent - select only recent messages from a mass-check log
+# [optionally only select messages with set=x]
sub usage { die "
-usage: log-grep-recent --months num_months < full.log > recent.log
+usage: log-grep-recent --months num_months [--set x] < full.log > recent.log
\n"; }
@@ -30,9 +31,11 @@
use warnings;
my $months = 0;
+my $set;
use Getopt::Long qw(:config bundling auto_help);
GetOptions(
- "m|months=f" => \$months
+ "m|months=f" => \$months,
+ "s|set=f" => \$set
) or usage();
usage() unless ($months > 0);
@@ -44,8 +47,13 @@
my %buckets = ();
while (<>) {
- if (/^[Y\.]\s+-?\d+.*\btime=(\d+)\b/) {
+ if (/^[Y\.]\s+-?\d+.*?\btime=(\d+)\b.*?\bset=(\d)\b/) {
my $t = $1;
+ my $s = $2;
+
+ if (defined $set && $set != $s) {
+ next;
+ }
my $monthsago = int (($now - $t) / $roughly1month);
$buckets{$monthsago}++;