From 227de8007a4630e04069bd8a40692516e8fb27f2 Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Tue, 13 Nov 2012 12:08:32 +0100 Subject: [PATCH] Fix number of queries in progress bar with tsung output. --- pgbadger | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pgbadger b/pgbadger index 41e811e..7dcf579 100755 --- a/pgbadger +++ b/pgbadger @@ -101,6 +101,7 @@ my $enable_log_duration = 0; my $remove_comment = 0; my $select_only = 0; my $enable_log_min_duration = 0; +my $tsung_queries = 0; my $NUMPROGRESS = 10000; my @DIMENSIONS = (800, 300); @@ -3723,6 +3724,7 @@ sub store_tsung_session print $fh " \n" if ($sec > 0); print $fh " \n"; for (my $i = 0; $i <= $#{$tsung_session{$pid}{queries}}; $i++) { + $tsung_queries++; $sec = 0; if ($i > 0) { $sec = $tsung_session{$pid}{dates}[$i] - $tsung_session{$pid}{dates}[$i - 1]; @@ -4092,11 +4094,19 @@ sub progress_bar $width ||= 25; $char ||= '='; my $num_width = length $total; - sprintf( - "[%-${width}s] Parsed %${num_width}s bytes of %s (%.2f%%), queries: %d, events: %d\r", - $char x (($width - 1) * $got / $total) . '>', - $got, $total, 100 * $got / +$total, $overall_stat{'queries_number'}, $overall_stat{'errors_number'} - ); + if ($extension eq 'tsung') { + sprintf( + "[%-${width}s] Parsed %${num_width}s bytes of %s (%.2f%%), queries: %d\r", + $char x (($width - 1) * $got / $total) . '>', + $got, $total, 100 * $got / +$total, $tsung_queries + ); + } else { + sprintf( + "[%-${width}s] Parsed %${num_width}s bytes of %s (%.2f%%), queries: %d, events: %d\r", + $char x (($width - 1) * $got / $total) . '>', + $got, $total, 100 * $got / +$total, $overall_stat{'queries_number'}, $overall_stat{'errors_number'} + ); + } } sub flotr2_graph -- 2.40.0