]> granicus.if.org Git - pgbadger/commitdiff
Add restartpoint reporting
authorGuillaume Lelarge <guillaume@lelarge.info>
Wed, 10 Apr 2013 16:32:23 +0000 (18:32 +0200)
committerGuillaume Lelarge <guillaume@lelarge.info>
Wed, 10 Apr 2013 16:32:23 +0000 (18:32 +0200)
Table and graph...

pgbadger

index adee04ac0e1446bb94f504b0d74caf54a88c5900..917833c314faaf8fbf97c6bc6a7b0ec412c5bdcf 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -607,6 +607,7 @@ my %application_info    = ();
 my %session_info        = ();
 my %conn_received       = ();
 my %checkpoint_info     = ();
+my %restartpoint_info   = ();
 my %autovacuum_info     = ();
 my %autoanalyze_info    = ();
 my @graph_values        = ();
@@ -909,7 +910,7 @@ Options:
     --disable-connection   : do not generate connection report.
     --disable-lock         : do not generate lock report.
     --disable-temporary    : do not generate temporary report.
-    --disable-checkpoint   : do not generate checkpoint report.
+    --disable-checkpoint   : do not generate checkpoint/restartpoint report.
     --disable-autovacuum   : do not generate autovacuum report.
 
 Examples:
@@ -971,6 +972,7 @@ sub init_stats_vars
        %session_info        = ();
        %conn_received       = ();
        %checkpoint_info     = ();
+       %restartpoint_info   = ();
        %autovacuum_info     = ();
        %autoanalyze_info    = ();
        @graph_values        = ();
@@ -2232,7 +2234,7 @@ div#littleToc a:hover { text-decoration:none; background-color:#DDDDDD; }
 .sql .nu0 {color: #cc66cc;}
 .sql span.xtra { display:block; }
 
-#queriespersecond_graph, #connectionspersecond_graph, #allqueries_graph, #checkpointwritebuffers_graph, #checkpointfiles_graph, #temporaryfile_graph, #autovacuum_graph, #selectqueries_graph, #writequeries_graph {
+#queriespersecond_graph, #connectionspersecond_graph, #allqueries_graph, #checkpointwritebuffers_graph, #checkpointfiles_graph, #restartpointwritebuffers_graph, #temporaryfile_graph, #autovacuum_graph, #selectqueries_graph, #writequeries_graph {
        width : 1025px;
        height: 400px;
        background:#F3F2ED;
@@ -2867,7 +2869,7 @@ sub dump_as_html
        }
 
        if (!$disable_hourly && (scalar keys %per_hour_info > 0)) {
-               if ($tempfile_info{count} || exists $checkpoint_info{chronos} || exists $autovacuum_info{chronos} ) {
+               if ($tempfile_info{count} || exists $checkpoint_info{chronos} || exists $restartpoint_info{chronos} || exists $autovacuum_info{chronos} ) {
                        print $fh qq{<table class="HourStatsTable"><tr><th rowspan="2">Day</th><th rowspan="2">Hour</th>};
                }
                if ($tempfile_info{count}) {
@@ -2881,10 +2883,15 @@ sub dump_as_html
                if (exists $checkpoint_info{warning}) {
                        print $fh qq{<th colspan="2">Checkpoint warning</th>};
                }
+               if ($restartpoint_info{wbuffer}) {
+                       if (exists $restartpoint_info{chronos}) {
+                               print $fh qq{<th colspan="4">Restartpoints</th>};
+                       }
+               }
                if (exists $autovacuum_info{chronos}) {
                        print $fh "             <th colspan=\"2\">Autovacuum</th>\n";
                }
-               if ($tempfile_info{count} || exists $checkpoint_info{chronos}) {
+               if ($tempfile_info{count} || exists $checkpoint_info{chronos} || exists $restartpoint_info{chronos}) {
                        print $fh qq{</tr><tr>};
                }
                if ($tempfile_info{count}) {
@@ -2897,10 +2904,14 @@ sub dump_as_html
                if (exists $checkpoint_info{warning}) {
                        print $fh qq{<th>Count</th><th>Avg time (sec)</th>};
                }
+               if ($restartpoint_info{wbuffer}) {
+                       print $fh
+       qq{<th>Wrote buffers</th><th>Write time (sec)</th><th>Sync time (sec)</th><th>Total time (sec)</th>};
+               }
                if (exists $autovacuum_info{chronos}) {
                        print $fh "             <th>VACUUMs</th><th>ANALYZEs</th>\n";
                }
-               if ($tempfile_info{count} || exists $checkpoint_info{chronos}) {
+               if ($tempfile_info{count} || exists $checkpoint_info{chronos} || exists $restartpoint_info{chronos}) {
                        print $fh qq{</tr>};
                        foreach my $d (sort {$a <=> $b} keys %per_hour_info) {
                                my $c = 1;
@@ -2950,6 +2961,18 @@ sub dump_as_html
                                                        print $fh "<td class=\"right\">0</td><td class=\"right\">0</td>";
                                                }
                                        }
+                                       if (exists $restartpoint_info{chronos} && $restartpoint_info{wbuffer}) {
+                                               if (exists $restartpoint_info{chronos}{$d}{$h}) {
+                                                       print $fh "<td class=\"right\">", &comma_numbers($restartpoint_info{chronos}{$d}{$h}{wbuffer}) || 0,
+                                                               "</td><td class=\"right\">", &comma_numbers($restartpoint_info{chronos}{$d}{$h}{write}) || 0,
+                                                               "</td><td class=\"right\">", &comma_numbers($restartpoint_info{chronos}{$d}{$h}{sync})  || 0,
+                                                               "</td><td class=\"right\">", &comma_numbers($restartpoint_info{chronos}{$d}{$h}{total}) || 0,
+                                                               "</td>";
+                                               } else {
+                                                       print $fh
+"<td class=\"right\">0</td><td class=\"right\">0</td><td class=\"right\">0</td><td class=\"right\">0</td>";
+                                               }
+                                       }
                                        if (exists $autovacuum_info{chronos}) {
                                                print $fh "<td class=\"right\">", &comma_numbers($autovacuum_info{chronos}{"$d"}{"$h"}{count} || 0), "</td>",
                                                          "<td class=\"right\">", &comma_numbers($autoanalyze_info{chronos}{"$d"}{"$h"}{count} || 0), "</td>";
@@ -3009,6 +3032,28 @@ sub dump_as_html
                        $d3 = '';
                }
 
+               # restartpoint size
+               if (exists $restartpoint_info{chronos} && $restartpoint_info{wbuffer}) {
+                       foreach my $tm (sort {$a <=> $b} keys %{$restartpoint_info{chronos}}) {
+                               $tm =~ /(\d{4})(\d{2})(\d{2})/;
+                               my $y  = $1 - 1900;
+                               my $mo = $2 - 1;
+                               my $d  = $3;
+                               foreach my $h ("00" .. "23") {
+                                       my $t = timegm_nocheck(0, 0, $h, $d, $mo, $y) * 1000;
+                                       next if ($t < $t_min_hour);
+                                       last if ($t > $t_max_hour);
+                                       $d1 .= "[$t, " . ($restartpoint_info{chronos}{$tm}{$h}{wbuffer} || 0) . "],";
+                               }
+                       }
+                       $d1 =~ s/,$//;
+                       &flotr2_graph(
+                               6,         'restartpointwritebuffers_graph', $d1, '', '', 'Restartpoint write buffers',
+                               'Buffers', 'Write buffers',                '',  ''
+                       );
+                       $d1 = '';
+               }
+
                # Temporary file size
                if (exists $tempfile_info{chronos}) {
                        foreach my $tm (sort {$a <=> $b} keys %{$tempfile_info{chronos}}) {
@@ -4072,6 +4117,7 @@ sub load_stats
        my %_database_info = %{$stats{database_info}};
        my %_application_info = %{$stats{application_info}};
        my %_checkpoint_info = %{$stats{checkpoint_info}};
+       my %_restartpoint_info = %{$stats{restartpoint_info}};
        my %_session_info = %{$stats{session_info}};
        my %_tempfile_info = %{$stats{tempfile_info}};
        my %_logs_type = %{$stats{logs_type}};
@@ -4442,6 +4488,21 @@ sub load_stats
                }
        }
 
+       ### restartpoint_info ###
+       $restartpoint_info{sync} += $_restartpoint_info{sync};
+       $restartpoint_info{wbuffer} += $_restartpoint_info{wbuffer};
+       $restartpoint_info{total} += $_restartpoint_info{total};
+       $restartpoint_info{write} += $_restartpoint_info{write};
+
+       foreach my $day (keys %{ $_restartpoint_info{chronos} }) {
+               foreach my $hour (keys %{ $_restartpoint_info{chronos}{$day} }) {
+                       $restartpoint_info{chronos}{$day}{$hour}{sync} += $_restartpoint_info{chronos}{$day}{$hour}{sync};
+                       $restartpoint_info{chronos}{$day}{$hour}{wbuffer} += $_restartpoint_info{chronos}{$day}{$hour}{wbuffer};
+                       $restartpoint_info{chronos}{$day}{$hour}{total} += $_restartpoint_info{chronos}{$day}{$hour}{total};
+                       $restartpoint_info{chronos}{$day}{$hour}{write} += $_restartpoint_info{chronos}{$day}{$hour}{write};
+               }
+       }
+
        #### Autovacuum infos ####
 
        $autovacuum_info{count} += $_autovacuum_info{count};
@@ -4486,6 +4547,7 @@ sub dump_as_binary
                'database_info' => \%database_info,
                'application_info' => \%application_info,
                'checkpoint_info' => \%checkpoint_info,
+               'restartpoint_info' => \%restartpoint_info,
                'session_info' => \%session_info,
                'tempfile_info' => \%tempfile_info,
                'error_info' => \%error_info,
@@ -4892,6 +4954,31 @@ sub parse_query
                return;
        }
 
+       # Store restartpoint information
+       if (
+               ($prefix_vars{'t_loglevel'} eq 'LOG')
+               && ($prefix_vars{'t_query'} =~
+/restartpoint complete: wrote (\d+) buffers \(([^\)]+)\); write=([0-9\.]+) s, sync=([0-9\.]+) s, total=([0-9\.]+) s/
+                  )
+          )
+       {
+               return if ($disable_checkpoint);
+               $restartpoint_info{wbuffer} += $1;
+
+               #$restartpoint_info{percent_wbuffer} += $2;
+               $restartpoint_info{write}         += $3;
+               $restartpoint_info{sync}          += $4;
+               $restartpoint_info{total}         += $5;
+
+               $restartpoint_info{chronos}{$date_part}{$prefix_vars{'t_hour'}}{wbuffer} += $1;
+
+               #$restartpoint_info{chronos}{$date_part}{$prefix_vars{'t_hour'}}{percent_wbuffer} += $2;
+               $restartpoint_info{chronos}{$date_part}{$prefix_vars{'t_hour'}}{write}         += $3;
+               $restartpoint_info{chronos}{$date_part}{$prefix_vars{'t_hour'}}{sync}          += $4;
+               $restartpoint_info{chronos}{$date_part}{$prefix_vars{'t_hour'}}{total}         += $5;
+               return;
+       }
+
        # Store the detail of the error
        if ($cur_info{$t_pid}{loglevel} =~ /WARNING|ERROR|FATAL|PANIC/) {
                if ($prefix_vars{'t_loglevel'} =~ /(DETAIL|STATEMENT|CONTEXT|HINT)/) {