From ebefb7fc032d4c984df7afbbb7251f40e14a4d88 Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Tue, 15 Apr 2014 11:29:25 +0200 Subject: [PATCH] Fix error details in incremental mode in Most Frequent Errors/Events report. Thanks to Herve Werner for the report. --- pgbadger | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/pgbadger b/pgbadger index d28cb6b..a5134af 100644 --- a/pgbadger +++ b/pgbadger @@ -2426,7 +2426,7 @@ sub set_top_error_sample # Stop when we have our number of samples if (!exists $error_info{$q}{date} || ($#{$error_info{$q}{date}} < $sample)) { - if ( ($q =~ /deadlock detected/) || ($real_error && !grep(/\Q$real_error\E/, @{$error_info{$q}{error}})) ) { + if ( ($q =~ /deadlock detected/) || ($real_error && !grep(/^\Q$real_error\E$/, @{$error_info{$q}{error}})) ) { push(@{$error_info{$q}{date}}, $date); push(@{$error_info{$q}{detail}}, $detail); push(@{$error_info{$q}{context}}, $context); @@ -7631,24 +7631,19 @@ sub load_stats foreach my $q (keys %_error_info) { $error_info{$q}{count} += $_error_info{$q}{count}; - # Keep only the wanted sample number - if (!exists $error_info{$q}{date} || ($#{$error_info{$q}{date}} < $sample)) { - push(@{$error_info{$q}{date}}, @{$_error_info{$q}{date}}); - push(@{$error_info{$q}{detail}}, @{$_error_info{$q}{detail}}); - push(@{$error_info{$q}{context}}, @{$_error_info{$q}{context}}); - push(@{$error_info{$q}{statement}}, @{$_error_info{$q}{statement}}); - push(@{$error_info{$q}{hint}}, @{$_error_info{$q}{hint}}); - push(@{$error_info{$q}{error}}, @{$_error_info{$q}{error}}); - push(@{$error_info{$q}{db}}, @{$_error_info{$q}{db}}); - foreach my $day (keys %{ $_error_info{$q}{chronos} }) { - foreach my $hour (keys %{$_error_info{$q}{chronos}{$day}}) { - $error_info{$q}{chronos}{$day}{$hour}{count} += $_error_info{$q}{chronos}{$day}{$hour}{count}; - foreach my $min (keys %{$_error_info{$q}{chronos}{$day}{$hour}{min}}) { - $error_info{$q}{chronos}{$day}{$hour}{min}{$min} += $_error_info{$q}{chronos}{$day}{$hour}{min}{$min}; - } + foreach my $day (keys %{ $_error_info{$q}{chronos} }) { + foreach my $hour (keys %{$_error_info{$q}{chronos}{$day}}) { + $error_info{$q}{chronos}{$day}{$hour}{count} += $_error_info{$q}{chronos}{$day}{$hour}{count}; + foreach my $min (keys %{$_error_info{$q}{chronos}{$day}{$hour}{min}}) { + $error_info{$q}{chronos}{$day}{$hour}{min}{$min} += $_error_info{$q}{chronos}{$day}{$hour}{min}{$min}; } } } + for (my $i = 0; $i <= $#{$_error_info{$q}{date}}; $i++) { + &set_top_error_sample($q, $_error_info{$q}{date}[$i], $_error_info{$q}{error}[$i], + $_error_info{$q}{detail}[$i], $_error_info{$q}{context}[$i], $_error_info{$q}{statement}[$i], + $_error_info{$q}{hint}[$i], $_error_info{$q}{db}[$i]); + } } ### per_minute_info ### -- 2.50.1