From 0ae16f8c95c375f7f547a9e95f25109cf2e614ce Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Fri, 5 Jul 2013 16:54:17 +0200 Subject: [PATCH] Fix count in Query type report. --- pgbadger | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/pgbadger b/pgbadger index cd40206..37ee2b9 100755 --- a/pgbadger +++ b/pgbadger @@ -1595,6 +1595,8 @@ sub comma_numbers { return 0 if ($#_ < 0); + return 0 if (!$_[0]); + my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1$num_sep/g; @@ -3039,45 +3041,48 @@ sub print_checkpoint_tempfile_vacuum_reports if (scalar keys %per_minute_info > 0) { - if ($tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer} || exists $autovacuum_info{chronos} || $autovacuum_info{count}) { + #if (exists $tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer} || exists $autovacuum_info{chronos} || exists $autovacuum_info{count}) { + if ($tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer} || exists $autovacuum_info{chronos} || exists $autovacuum_info{count}) { print $fh qq{}; + } else { + return; } - if ($tempfile_info{count}) { + if (exists $tempfile_info{count}) { print $fh qq{}; } - if ($checkpoint_info{wbuffer}) { + if (exists $checkpoint_info{wbuffer}) { print $fh qq{}; } if (exists $checkpoint_info{warning}) { print $fh qq{}; } - if ($restartpoint_info{wbuffer}) { + if (exists $restartpoint_info{wbuffer}) { print $fh qq{}; } if (exists $autovacuum_info{chronos}) { print $fh " \n"; } - if ($tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer}) { + if (exists $tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer}) { print $fh qq{}; } - if ($tempfile_info{count}) { + if (exists $tempfile_info{count}) { print $fh qq{}; } - if ($checkpoint_info{wbuffer}) { + if (exists $checkpoint_info{wbuffer}) { print $fh qq{}; } if (exists $checkpoint_info{warning}) { print $fh qq{}; } - if ($restartpoint_info{wbuffer}) { + if (exists $restartpoint_info{wbuffer}) { print $fh qq{}; } if (exists $autovacuum_info{chronos}) { print $fh " \n"; } - if ($tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer}) { + if (exists $tempfile_info{count} || exists $checkpoint_info{wbuffer} || exists $restartpoint_info{wbuffer}) { print $fh qq{}; foreach my $d (sort {$a <=> $b} keys %per_minute_info) { my $c = 1; @@ -3425,8 +3430,8 @@ sub print_query_type_report my $r = 0; foreach my $a (@SQL_ACTION) { - print $fh "\n"; + print $fh "\n"; ($r > 0) ? $r = 0 : $r = 1; } print $fh "
DayHourTemporary filesCheckpointsCheckpoint warningRestartpointsAutovacuum
CountAvg sizeWritten buffersAddedRemovedRecycledWrite time (sec)Sync time (sec)Total time (sec)CountAvg time (sec)Written buffersWrite time (sec)Sync time (sec)Total time (sec)VACUUMsANALYZEs
$a", &comma_numbers($overall_stat{'$a'}), - "", sprintf("%0.2f", ($overall_stat{$a} * 100) / $total), "%
$a", &comma_numbers($overall_stat{$a}), + "", sprintf("%0.2f", ($overall_stat{$a} * 100) / $total), "%
OTHERS", &comma_numbers($total - $totala), -- 2.40.0