From: Darold Date: Sun, 24 Jun 2012 10:18:28 +0000 (+0200) Subject: Fix hourly temporary file stat empty output X-Git-Tag: v3.2~221 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b57113922458ef29e917ed9b6bdd5d4f5058198;p=pgbadger Fix hourly temporary file stat empty output --- diff --git a/pgbadger b/pgbadger index 4b259ee..bc5a98f 100755 --- a/pgbadger +++ b/pgbadger @@ -1430,7 +1430,7 @@ sub dump_as_html $per_hour_info{$d}{$h}{average} = $per_hour_info{$d}{$h}{duration} / ($per_hour_info{$d}{$h}{count} || 1); $per_hour_info{$d}{$h}{'SELECT'}{average} = $per_hour_info{$d}{$h}{'SELECT'}{duration} / ($per_hour_info{$d}{$h}{'SELECT'}{count} || 1); my $write_average = (($per_hour_info{$d}{$h}{'INSERT'}{duration}+$per_hour_info{$d}{$h}{'UPDATE'}{duration}+$per_hour_info{$d}{$h}{'DELETE'}{duration})||0)/(($per_hour_info{$d}{$h}{'INSERT'}{count}+$per_hour_info{$d}{$h}{'UPDATE'}{count}+$per_hour_info{$d}{$h}{'DELETE'}{count})||1); - print $fh "$zday$h", &comma_numbers($per_hour_info{$d}{$h}{count}), "", &convert_time($per_hour_info{$d}{$h}{average}), "",&comma_numbers($per_hour_info{$d}{$h}{'SELECT'}{count}||0), "", &convert_time($per_hour_info{$d}{$h}{'SELECT'}{average}||0), "", &comma_numbers($per_hour_info{$d}{$h}{'INSERT'}{count}||0), "", &comma_numbers($per_hour_info{$d}{$h}{'UPDATE'}{count}||0), "", &comma_numbers($per_hour_info{$d}{$h}{'DELETE'}{count}||0), "", &convert_time($write_average), ""; + print $fh "$zday$h", &comma_numbers($per_hour_info{$d}{$h}{count}), "", &convert_time($per_hour_info{$d}{$h}{average}), "",&comma_numbers($per_hour_info{$d}{$h}{'SELECT'}{count}||0), "", &convert_time($per_hour_info{$d}{$h}{'SELECT'}{average}||0), "", &comma_numbers($per_hour_info{$d}{$h}{'INSERT'}{count}||0), "", &comma_numbers($per_hour_info{$d}{$h}{'UPDATE'}{count}||0), "", &comma_numbers($per_hour_info{$d}{$h}{'DELETE'}{count}||0), "", &convert_time($write_average), "\n"; $c++; } } @@ -1569,12 +1569,14 @@ sub dump_as_html Checkpoints }; } - print $fh qq{ + if ($tempfile_info{count} || exists $checkpoint_info{chronos}) { + print $fh qq{ }; + } if ($tempfile_info{count}) { - print $fh qq{ + print $fh qq{ Count Av. size }; @@ -1590,37 +1592,38 @@ sub dump_as_html Total time (sec) }; } - print $fh qq{ + if ($tempfile_info{count} || exists $checkpoint_info{chronos}) { + print $fh qq{ }; - - foreach my $d (sort {$a <=> $b} keys %per_hour_info) { - my $c = 1; - $d =~ /^\d{4}(\d{2})(\d{2})$/; - my $zday = "$abbr_month{$1} $2"; - foreach my $h (sort {$a <=> $b} keys %{$per_hour_info{$d}}) { - my $colb = $c % 2; - $zday = " " if ($c > 1); - print $fh "$zday$h"; - if ($tempfile_info{count}) { - my $temp_average = '0'; - if ($tempfile_info{chronos}{$d}{$h}{count}) { - $temp_average = &comma_numbers(sprintf("%.2f", $tempfile_info{chronos}{$d}{$h}{size}/$tempfile_info{chronos}{$d}{$h}{count})); + foreach my $d (sort {$a <=> $b} keys %per_hour_info) { + my $c = 1; + $d =~ /^\d{4}(\d{2})(\d{2})$/; + my $zday = "$abbr_month{$1} $2"; + foreach my $h (sort {$a <=> $b} keys %{$per_hour_info{$d}}) { + my $colb = $c % 2; + $zday = " " if ($c > 1); + print $fh "$zday$h"; + if ($tempfile_info{count}) { + my $temp_average = '0'; + if ($tempfile_info{chronos}{$d}{$h}{count}) { + $temp_average = &comma_numbers(sprintf("%.2f", $tempfile_info{chronos}{$d}{$h}{size}/$tempfile_info{chronos}{$d}{$h}{count})); + } + print $fh "", &comma_numbers($tempfile_info{chronos}{$d}{$h}{count} || 0), "$temp_average"; } - print $fh "", &comma_numbers($tempfile_info{chronos}{$d}{$h}{count} || 0), "$temp_average"; - } - if (exists $checkpoint_info{chronos}) { - if (exists $checkpoint_info{chronos}{$d}{$h}) { - print $fh "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{wbuffer}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{file_added}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{file_removed}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{file_recycled}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{write}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{sync}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{total}) || 0, ""; - } else { - print $fh "0000000"; + if (exists $checkpoint_info{chronos}) { + if (exists $checkpoint_info{chronos}{$d}{$h}) { + print $fh "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{wbuffer}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{file_added}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{file_removed}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{file_recycled}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{write}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{sync}) || 0, "", &comma_numbers($checkpoint_info{chronos}{$d}{$h}{total}) || 0, ""; + } else { + print $fh "0000000"; + } } + print $fh "\n"; + $c++; } - print $fh "\n"; - $c++; } + print $fh "\n"; } - print $fh "\n"; # checkpoint size if (exists $checkpoint_info{chronos}) {