From: Darold Gilles Date: Sun, 11 Jun 2017 15:58:44 +0000 (+0200) Subject: Add report of checkpoint distance and estimate. Thanks to jjsantam for the feature... X-Git-Tag: v9.2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b36bdb0ac262ed59e5837964ed0514942a0ac19b;p=pgbadger Add report of checkpoint distance and estimate. Thanks to jjsantam for the feature request. --- diff --git a/pgbadger b/pgbadger index 78087da..474f30f 100644 --- a/pgbadger +++ b/pgbadger @@ -4798,6 +4798,7 @@ sub html_header @@ -7384,6 +7385,15 @@ sub print_checkpoint $chk_dataavg{file_recycled}{"$rd"} += ($per_minute_info{$tm}{$h}{$m}{checkpoint}{file_recycled} || 0); } } + if (exists $checkpoint_info{distance} || exists $checkpoint_info{estimate}) { + $chk_dataavg{distance}{"$rd"} = 0 if (!exists $chk_dataavg{distance}{"$rd"}); + $chk_dataavg{estimate}{"$rd"} = 0 if (!exists $chk_dataavg{estimate}{"$rd"}); + if (exists $per_minute_info{$tm}{$h}{$m}{checkpoint}) { + $chk_dataavg{distance}{"$rd"} += ($per_minute_info{$tm}{$h}{$m}{checkpoint}{distance} || 0) * 1000; + $chk_dataavg{distance_count}{"$rd"} += ($per_minute_info{$tm}{$h}{$m}{checkpoint}{distance_count} || 1); + $chk_dataavg{estimate}{"$rd"} += ($per_minute_info{$tm}{$h}{$m}{checkpoint}{estimate} || 0) * 1000; + } + } } foreach my $rd (@avgs) { @@ -7400,6 +7410,10 @@ sub print_checkpoint $graph_data{file_removed} .= "[$t, " . ($chk_dataavg{file_removed}{"$rd"} || 0) . "],"; $graph_data{file_recycled} .= "[$t, " . ($chk_dataavg{file_recycled}{"$rd"} || 0) . "],"; } + if (exists $chk_dataavg{distance} || $chk_dataavg{estimate}) { + $graph_data{distance} .= "[$t, " . int(($chk_dataavg{distance}{"$rd"}/($chk_dataavg{distance_count}{"$rd"} || 1)) || 0) . "],"; + $graph_data{estimate} .= "[$t, " . int(($chk_dataavg{estimate}{"$rd"}/($chk_dataavg{distance_count}{"$rd"} || 1)) || 0) . "],"; + } } } } @@ -7419,6 +7433,12 @@ sub print_checkpoint 'Number of files', 'Added', 'Removed', 'Recycled' ); + $drawn_graphs{checkpointdistance_graph} = + &jqplot_linegraph($graphid++, 'checkpointdistance_graph', $graph_data{distance}, + $graph_data{estimate}, '', 'Checkpoint mean distance and estimate (' . $avg_minutes . ' minutes period)', + 'Number of bytes', 'distance', 'estimate' + ); + my $checkpoint_wbuffer_peak = 0; my $checkpoint_wbuffer_peak_date = ''; foreach (sort {$overall_checkpoint{'peak'}{$b}{checkpoint_wbuffer} <=> $overall_checkpoint{'peak'}{$a}{checkpoint_wbuffer}} keys %{$overall_checkpoint{'peak'}}) { @@ -7476,9 +7496,28 @@ $drawn_graphs{checkpointfiles_graph} }; delete $drawn_graphs{checkpointfiles_graph}; + print $fh qq{ +
+

Checkpoints distance

+
+

Key values

+
+
    +
+
+
+
+$drawn_graphs{checkpointdistance_graph} +
+
+}; + delete $drawn_graphs{checkpointdistance_graph}; + + my $buffers = ''; my $files = ''; my $warnings = ''; + my $distance = ''; foreach my $d (sort {$a <=> $b} keys %per_minute_info) { $d =~ /^\d{4}(\d{2})(\d{2})$/; my $zday = "$abbr_month{$1} $2"; @@ -7486,11 +7525,13 @@ $drawn_graphs{checkpointfiles_graph} $buffers .= "$zday$h"; $files .= "$zday$h"; $warnings .= "$zday$h"; + $distance .= "$zday$h"; $zday = ''; my %cinf = (); my %rinf = (); my %cainf = (); my %rainf = (); + my %dinf = (); foreach my $m (keys %{$per_minute_info{$d}{$h}}) { if (exists $per_minute_info{$d}{$h}{$m}{checkpoint}) { @@ -7510,6 +7551,11 @@ $drawn_graphs{checkpointfiles_graph} $cinf{warning} += $per_minute_info{$d}{$h}{$m}{checkpoint}{warning}; $cinf{warning_seconds} += $per_minute_info{$d}{$h}{$m}{checkpoint}{warning_seconds}; } + if (exists $per_minute_info{$d}{$h}{$m}{checkpoint}{distance} || $per_minute_info{$d}{$h}{$m}{checkpoint}{estimate}) { + $dinf{distance}{sum} += $per_minute_info{$d}{$h}{$m}{checkpoint}{distance}; + $dinf{estimate}{sum} += $per_minute_info{$d}{$h}{$m}{checkpoint}{estimate}; + $dinf{distance}{count} += $per_minute_info{$d}{$h}{$m}{checkpoint}{distance_count}; + } } if (scalar keys %cinf) { $buffers .= "" . &comma_numbers($cinf{wbuffer}) . @@ -7535,12 +7581,20 @@ $drawn_graphs{checkpointfiles_graph} } else { $warnings .= "00s"; } + if (exists $dinf{distance} || $dinf{estimate}) { + $distance .= "" . &comma_numbers(sprintf( "%.2f", $dinf{distance}{sum}/$dinf{distance}{count})) . " kB" . + &comma_numbers(sprintf( "%.2f", $dinf{estimate}{sum}/$dinf{distance}{count})) . + " kB"; + } else { + $distance .= "00"; + } } } $buffers = qq{$NODATA} if (!$buffers); $files = qq{$NODATA} if (!$files); $warnings = qq{$NODATA} if (!$warnings); + $distance = qq{$NODATA} if (!$distance); print $fh qq{
@@ -7550,6 +7604,7 @@ $drawn_graphs{checkpointfiles_graph}
  • Checkpoints Buffers
  • Checkpoints files
  • Checkpoints Warnings
  • +
  • Checkpoints distance
  • @@ -7599,6 +7654,20 @@ $drawn_graphs{checkpointfiles_graph} $warnings +
    +
    + + + + + + + + + + $distance + +
    DayHourMean distanceMean estimate
    Back to the top of the Checkpoint Activity table @@ -12738,7 +12807,7 @@ sub parse_query ) ) { - # Example: LOG: checkpoint complete: wrote 175 buffers (5.7%); 0 transaction log file(s) added, 1 removed, 2 recycled; write=17.437 s, sync=0.722 s, total=18.259 s; sync files=2, longest=0.708 s, average=0.361 s + # Example: LOG: checkpoint complete: wrote 8279 buffers (50.5%); 0 transaction log file(s) added, 0 removed, 0 recycled; write=2.277 s, sync=0.194 s, total=2.532 s; sync files=13, longest=0.175 s, average=0.014 s; distance=402024 kB, estimate=402024 kB return if ($disable_checkpoint); $checkpoint_info{wbuffer} += $1; @@ -12774,6 +12843,23 @@ sub parse_query if ($2 > $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{sync_longest}); $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{sync_avg} += $3; } + + # 9.6: LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 transaction log file(s) added, 1 removed, 0 recycled; write=0.016 s, sync=0.000 s, total=0.054 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=14744 kB + if ($prefix_vars{'t_query'} =~ /; distance=(\d+) kB, estimate=(\d+) kB/) { + $checkpoint_info{distance} += $1; + $checkpoint_info{estimate} += $2; + if ($1 > $overall_checkpoint{distance}) { + $overall_checkpoint{distance} = $1; + } + if ($2 > $overall_checkpoint{estimate}) { + $overall_checkpoint{estimate} = $2; + } + $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{distance} += $1; + $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{distance_count}++; + $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{estimate} += $2; + $overall_checkpoint{'peak'}{$cur_last_log_timestamp}{distance} += $1; + $overall_checkpoint{'peak'}{$cur_last_log_timestamp}{estimate} += $2; + } return; } @@ -12820,7 +12906,21 @@ sub parse_query if ($7 > $overall_checkpoint{checkpoint_sync}) { $overall_checkpoint{checkpoint_sync} = $7; } - + if ($prefix_vars{'t_query'} =~ /distance=(\d+) kB, estimate=(\d+) kB/) { + $checkpoint_info{distance} += $1; + $checkpoint_info{estimate} += $2; + $overall_checkpoint{'peak'}{$cur_last_log_timestamp}{distance} += $1; + $overall_checkpoint{'peak'}{$cur_last_log_timestamp}{estimate} += $2; + if ($1 > $overall_checkpoint{distance}) { + $overall_checkpoint{distance} = $1; + } + if ($2 > $overall_checkpoint{estimate}) { + $overall_checkpoint{estimate} = $2; + } + $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{distance} += $1; + $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{distance_count}++; + $per_minute_info{$date_part}{$prefix_vars{'t_hour'}}{$prefix_vars{'t_min'}}{checkpoint}{estimate} += $2; + } return; }