]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add support of groups in rspamd_stats
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Apr 2018 10:37:11 +0000 (11:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 20 Apr 2018 10:37:29 +0000 (11:37 +0100)
utils/rspamd_stats.pl

index 3a8affce15f2a24be10a42c68ffd2b9aef9af52d..39a3debc2a69783071dcbf187c9df9e5af67208e 100755 (executable)
@@ -12,6 +12,8 @@ use strict;
 my @symbols_search;
 my @symbols_exclude;
 my @symbols_bidirectional;
+my @symbols_groups;
+my %groups;
 my $reject_score = 15.0;
 my $junk_score = 6.0;
 my $diff_alpha = 0.1;
@@ -41,6 +43,7 @@ GetOptions(
   "symbol|s=s@"           => \@symbols_search,
   "symbol-bidir|S=s@"     => \@symbols_bidirectional,
   "exclude|X=s@"          => \@symbols_exclude,
+  "group|g=s@"            => \@symbols_groups,
   "log|l=s"               => \$log_file,
   "alpha-score|alpha|a=f" => \$diff_alpha,
   "correlations|c"        => \$correlations,
@@ -93,6 +96,18 @@ foreach my $s (@symbols_bidirectional) {
   push @symbols_search, $s unless grep /^$s$/, @symbols_search;
 }
 
+# Deal with groups
+my $group_id = 0;
+foreach my $g (@symbols_groups) {
+  my @symbols = split /,/,$g;
+  my $group_name = "group$group_id";
+
+  foreach my $s (@symbols) {
+    $groups{$s} = $group_name;
+    push @symbols_search, $s unless grep /^$s$/, @symbols_search;
+  }
+}
+
 @symbols_search = '.*'
   unless @symbols_search;
 
@@ -508,6 +523,11 @@ sub ProcessLog {
 
             push @sym_names, $sym_name;
 
+            if ($groups{$s}) {
+              # Replace with group
+              $sym_name = $groups{$s};
+            }
+
             if (!$sym_res{$sym_name}) {
               $sym_res{$sym_name} = {
                 hits             => 0,