From 3f3a884e4563e53d6b9b6442ebe632522be6a37b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 20 Apr 2018 11:37:11 +0100 Subject: [PATCH] [Minor] Add support of groups in rspamd_stats --- utils/rspamd_stats.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl index 3a8affce1..39a3debc2 100755 --- a/utils/rspamd_stats.pl +++ b/utils/rspamd_stats.pl @@ -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, -- 2.39.5