From 44b94e247d1c719d9871a698fec27f67560ca5b3 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Wed, 7 Dec 2016 19:44:12 +0300 Subject: [Minor] rspamd_stats: add actions totals --- utils/rspamd_stats.pl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'utils/rspamd_stats.pl') diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl index e1618d14d..b845964ff 100644 --- a/utils/rspamd_stats.pl +++ b/utils/rspamd_stats.pl @@ -59,6 +59,7 @@ my %sym_res; my $rspamd_log; my $enabled = 0; +my %action; my %timeStamp; my %scanTime = ( max => 0, @@ -172,6 +173,8 @@ printf " [ %s / %s ] ", $timeStamp{'start'}, $timeStamp{'end'} if defined $timeStamp{'start'}; say ''; +printf "%11s: %d\n", $_, $action{$_} for sort keys %action; +say ''; printf "scan time min/avg/max = %.2f/%.2f/%.2f s ", $scanTime{'min'} / 1000, ($total) ? $scanTime{'total'} / $total / 1000 : undef, @@ -192,20 +195,21 @@ sub ProcessLog { if (/^.*rspamd_task_write_log.*$/) { $timeStamp{'end'} = join ' ', ( split /\s+/ )[ 0 .. 1 ]; - if ($_ !~ /\[(NaN|-?\d+(?:\.\d+)?)\/(-?\d+(?:\.\d+)?)\]\s+\[([^\]]+)\].+? time: (\d+\.\d+)ms real/) { + if ($_ !~ /\(([^()]+)\): \[(NaN|-?\d+(?:\.\d+)?)\/(-?\d+(?:\.\d+)?)\]\s+\[([^\]]+)\].+? time: (\d+\.\d+)ms real/) { #print "BAD: $_\n"; next; } $timeStamp{'start'} //= $timeStamp{'end'}; - $scanTime{'min'} = $4 - if ( !exists $scanTime{'min'} || $scanTime{'min'} > $4 ); - $scanTime{'max'} = $4 - if ( $scanTime{'max'} < $4 ); - $scanTime{'total'} += $4; + $scanTime{'min'} = $5 + if ( !exists $scanTime{'min'} || $scanTime{'min'} > $5 ); + $scanTime{'max'} = $5 + if ( $scanTime{'max'} < $5 ); + $scanTime{'total'} += $5; + $action{$1}++; $total ++; - my $score = $1 * 1.0; + my $score = $2 * 1.0; if ($score >= $reject_score) { $total_spam ++; @@ -215,7 +219,7 @@ sub ProcessLog { } # Symbols - my @symbols = split /(?:\{[^}]*\})?,/, $3; + my @symbols = split /(?:\{[^}]*\})?,/, $4; my @sym_names; foreach my $s (@symbols_search) { -- cgit v1.2.3