diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-12-27 20:54:06 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-12-27 20:54:06 +0300 |
commit | c396dd392d649f37e75b2085cdb6337fa9fbdd01 (patch) | |
tree | 8b9a73bf63134bf178a6c9d13d77942b8bcdc20f | |
parent | c520328e1944e4c0a9d706b0d38de6d61a975982 (diff) | |
download | rspamd-c396dd392d649f37e75b2085cdb6337fa9fbdd01.tar.gz rspamd-c396dd392d649f37e75b2085cdb6337fa9fbdd01.zip |
[Minor] rspamd_stats: Add progress indicator
-rwxr-xr-x | utils/rspamd_stats.pl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl index 2c40e347c..1f075b9bb 100755 --- a/utils/rspamd_stats.pl +++ b/utils/rspamd_stats.pl @@ -68,6 +68,8 @@ my $ham_junk_change = 0; my %sym_res; my $rspamd_log; my $enabled = 0; +my $log_file_num = 1; +my $spinner_update_time = 0; my %action; my %timeStamp; @@ -108,6 +110,10 @@ elsif ( -d "$log_file" ) { open( $rspamd_log, "-|", "$dc $log_dir/$_" ) or die "cannot execute $dc $log_dir/$_ : $!"; + printf "\033[J Parsing log files: [%d/%d] %s\033[G", $log_file_num++, scalar @logs, $_; + $spinner_update_time = 0; # Force spinner update + &spinner; + &ProcessLog; close($rspamd_log) @@ -337,6 +343,7 @@ sub ProcessLog { next if !$enabled; if (/^.*rspamd_task_write_log.*$/) { + &spinner; my $ts = ($is_syslog) ? syslog2iso( join ' ', ( split /\s+/ )[ 0 .. 2 ] ) @@ -528,7 +535,7 @@ sub GetLogfilesList { # Loop through array printing out filenames if (!$json) { - print "\nParsing log files:\n"; + print "\nLog files to process:\n"; foreach my $file (@logs) { print " $file\n"; } @@ -589,6 +596,14 @@ sub numeric { $a_num <=> $b_num; } +sub spinner { + my @spinner = qw{/ - \ |}; + return + if ( ( time - $spinner_update_time ) < 1 ); + printf "%s\033[1D", $spinner[ time % @spinner ]; + $spinner_update_time = time; +} + # Convert syslog timestamp to "ISO 8601 like" format # using current year as syslog does not record the year (nor the timezone) # or the last year if the guessed time is in the future. |