aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2016-11-14 17:28:34 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2016-11-14 17:28:34 +0300
commit9d187be27d08012b9b5fa63a2dd7bcf59106394f (patch)
tree3b9098a9a90c8c69190eb77bb0fbbbec10e47232 /utils
parentc721be33130b9ce461146d0ce5115197817a60ba (diff)
downloadrspamd-9d187be27d08012b9b5fa63a2dd7bcf59106394f.tar.gz
rspamd-9d187be27d08012b9b5fa63a2dd7bcf59106394f.zip
[Minor] rspamd_stats: add basic summary
Diffstat (limited to 'utils')
-rw-r--r--utils/rspamd_stats.pl33
1 files changed, 30 insertions, 3 deletions
diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl
index 53b65cef0..f360de8af 100644
--- a/utils/rspamd_stats.pl
+++ b/utils/rspamd_stats.pl
@@ -1,5 +1,6 @@
#!/usr/bin/env perl
+use 5.010;
use Data::Dumper;
use Getopt::Long;
use Pod::Usage;
@@ -58,6 +59,12 @@ my %sym_res;
my $rspamd_log;
my $enabled = 0;
+my %timeStamp;
+my %scanTime = (
+ max => 0,
+ total => 0,
+);
+
if ($log_file eq '-' || $log_file eq '') {
$rspamd_log = \*STDIN;
&ProcessLog();
@@ -158,6 +165,20 @@ Junk changes / total junk hits : %6d/%-6d (%7.3f%%)
}
}
+print "
+=== Summary ", '=' x 68, "
+Messages scanned: $total";
+printf " [ %s / %s ]
+", $timeStamp{'start'}, $timeStamp{'end'}
+ if defined $timeStamp{'start'};
+say '';
+printf "scan time min/avg/max = %.2f/%.2f/%.2f s
+", $scanTime{'min'} / 1000,
+ ($total) ? $scanTime{'total'} / $total / 1000 : undef,
+ $scanTime{'max'} / 1000
+ if exists $scanTime{'min'};
+say '=' x 80;
+
exit;
sub ProcessLog {
@@ -169,14 +190,20 @@ sub ProcessLog {
next if !$enabled;
if (/^.*rspamd_task_write_log.*$/) {
- my @elts = split /\s+/;
- my $ts = $elts[0] . ' ' . $elts[1];
+ $timeStamp{'end'} = join ' ', ( split /\s+/ )[ 0 .. 1 ];
- if ($_ !~ /\[(-?\d+(?:\.\d+)?)\/(-?\d+(?:\.\d+)?)\]\s+\[([^\]]+)\]/) {
+ if ($_ !~ /\[(-?\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;
+
$total ++;
my $score = $1 * 1.0;