aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-09 10:29:56 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-09 10:29:56 +0100
commita1e147e37c1916f44fbf7f88196f52dce9c5339b (patch)
treef42db9280386df110df2db5b0bfe1114b6918fe7 /utils
parent73119605ba71ce8d78188671d3cfda21dba5dc18 (diff)
downloadrspamd-a1e147e37c1916f44fbf7f88196f52dce9c5339b.tar.gz
rspamd-a1e147e37c1916f44fbf7f88196f52dce9c5339b.zip
[Feature] Add `--search-pattern` option to rspamd_stats
Diffstat (limited to 'utils')
-rw-r--r--utils/rspamd_stats.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl
index a3b41d838..8aeddade6 100644
--- a/utils/rspamd_stats.pl
+++ b/utils/rspamd_stats.pl
@@ -12,6 +12,7 @@ my $junk_score = 6.0;
my $diff_alpha = 0.1;
my $correlations = 0;
my $log_file = "";
+my $search_pattern = "";
my $man = 0;
my $help = 0;
@@ -22,6 +23,7 @@ GetOptions(
"log|l=s" => \$log_file,
"alpha|a=f" => \$diff_alpha,
"correlations|c" => \$correlations,
+ "search-pattern=s" => \$search_pattern,
"help|?" => \$help,
"man" => \$man
) or pod2usage(2);
@@ -43,6 +45,7 @@ my $ham_spam_change = 0;
my $ham_junk_change = 0;
my %sym_res;
my $rspamd_log;
+my $enabled = 0;
if ($log_file eq '-' || $log_file eq '') {
$rspamd_log = \*STDIN;
@@ -52,6 +55,12 @@ else {
}
while(<$rspamd_log>) {
+ if (!$enabled && ($search_pattern eq "" || /$search_pattern/)) {
+ $enabled = 1;
+ }
+
+ next if !$enabled;
+
if (/^.*rspamd_task_write_log.*$/) {
my @elts = split /\s+/;
my $ts = $elts[0] . ' ' . $elts[1];
@@ -254,6 +263,8 @@ rspamd_stats [options] [--symbol=SYM1 [--symbol=SYM2...]] [--log file]
--junk-score=score set junk score (6.0 by default)
--symbol=sym check specified symbol (perl regexps, '.*' by default)
--alpha=value set ignore score for symbols (0.1 by default)
+ --correlations enable correlations report
+ --search-pattern do not process input unless the desired pattern is found
--help brief help message
--man full documentation
@@ -281,6 +292,14 @@ Specifies the minimum score for a symbol to be considered by this script.
Add symbol or pattern (pcre format) to analyze.
+=item B<--correlations>
+
+Additionaly print correlation rate for each symbol displayed. This routine calculates merely paired correlations between symbols.
+
+=item B<--search-pattern>
+
+Do not process input unless finding the specified regular expression. Useful to skip logs to certain date, for example, --search-pattern="2016-08-09 10:00:0[0-9]"
+
=item B<--help>
Print a brief help message and exits.