}
+# We change temporary log level from LOG to ERROR
+# to store these messages into the error report
+sub change_log_level
+{
+ my $msg = shift;
+
+ return 1 if ($msg =~ /parameter "[^"]+" changed to "[^"]+"/);
+ return 1 if ($msg =~ /database system was/);
+ return 1 if ($msg =~ /recovery has paused/);
+ return 1 if ($msg =~ /ending cancel to blocking autovacuum/);
+ return 1 if ($msg =~ /skipping analyze of/);
+ return 1 if ($msg =~ /using stale statistics/);
+ return 1 if ($msg =~ /replication command:/);
+
+ return 0;
+}
+
+sub revert_log_level
+{
+ my $msg = shift;
+
+ return ($msg, 1) if ($msg =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/);
+ return ($msg, 1) if ($msg =~ s/ERROR: (database system was)/LOG: $1/);
+ return ($msg, 1) if ($msg =~ s/ERROR: (recovery has paused)/LOG: $1/);
+ return ($msg, 1) if ($msg =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/);
+ return ($msg, 1) if ($msg =~ s/ERROR: (skipping analyze of)/LOG: $1/);
+ return ($msg, 1) if ($msg =~ s/ERROR: (using stale statistics)/LOG: $1/);
+ return ($msg, 1) if ($msg =~ s/ERROR: (received replication command:)/LOG: $1/);
+
+ return ($msg, 0);
+}
+
sub show_error_as_text
{
return if (scalar keys %error_info == 0);
last if ($idx > $top);
last if (!$error_info{$k}{count});
- my $msg = $k;
- $msg =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/;
- $msg =~ s/ERROR: (database system was)/LOG: $1/;
- $msg =~ s/ERROR: (recovery has paused)/LOG: $1/;
- $msg =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/;
- $msg =~ s/ERROR: (skipping analyze of)/LOG: $1/;
- $msg =~ s/ERROR: (using stale statistics)/LOG: $1/;
+ my ($msg, $ret) = &revert_log_level($k);
if ($error_info{$k}{count} > 1) {
print $fh "$idx) " . &comma_numbers($error_info{$k}{count}) . " - $msg\n";
my $j = 1;
for (my $i = 0 ; $i <= $#{$error_info{$k}{date}} ; $i++) {
last if ($i == $sample);
- if ( ($error_info{$k}{error}[$i] =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (database system was)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (recovery has paused)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (skipping analyze of)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (using stale statistics)/LOG: $1/)
- )
- {
+ ($error_info{$k}{error}[$i], $ret) = &revert_log_level($error_info{$k}{error}[$i]);
+ if ($msg) {
$logs_type{ERROR}--;
$logs_type{LOG}++;
}
$j++;
}
} elsif ($error_info{$k}{error}[0]) {
- if ( ($error_info{$k}{error}[0] =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (database system was)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (recovery has paused)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (skipping analyze of)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (using stale statistics)/LOG: $1/)
- )
- {
+ ($error_info{$k}{error}[0], $ret) = &revert_log_level($error_info{$k}{error}[0]);
+ if ($msg) {
$logs_type{ERROR}--;
$logs_type{LOG}++;
}
my %graph_data = ();
foreach my $h ("00" .. "23") {
foreach my $rd (@histo_avgs) {
- $graph_data{count} .= "['$h:$rd'," . (int($hourly_count{"$h:$rd"}/$days) || 0) . "],";
+ $graph_data{count} .= "['$h:$rd'," . ($hourly_count{"$h:$rd"} || 0) . "],";
$graph_data{duration} .= "['$h:$rd'," . (int($hourly_duration{"$h:$rd"} / ($hourly_count{"$h:$rd"} || 1)) || 0) . "],";
}
}
$apps_involved = qq{<button type="button" class="btn btn-mini" data-toggle="collapse" data-target="#time-consuming-queries-app-involved-rank-$rank">App(s) involved</button>};
}
my $query_histo =
- &jqplot_histograph($graphid++, 'timeconsuming_graph_'.$rank, $graph_data{count}, $graph_data{duration}, 'Avg. queries', 'Avg. duration');
+ &jqplot_histograph($graphid++, 'timeconsuming_graph_'.$rank, $graph_data{count}, $graph_data{duration}, 'Queries', 'Avg. duration');
print $fh qq{
<tr>
my %graph_data = ();
foreach my $h ("00" .. "23") {
foreach my $rd (@histo_avgs) {
- $graph_data{count} .= "['$h:$rd'," . (int($hourly_count{"$h:$rd"}/$days) || 0) . "],";
+ $graph_data{count} .= "['$h:$rd'," . ($hourly_count{"$h:$rd"} || 0) . "],";
$graph_data{duration} .= "['$h:$rd'," . (int($hourly_duration{"$h:$rd"} / ($hourly_count{"$h:$rd"} || 1)) || 0) . "],";
}
}
%hourly_duration = ();
my $query_histo =
- &jqplot_histograph($graphid++, 'mostfrequent_graph_'.$rank, $graph_data{count}, $graph_data{duration}, 'Avg. queries', 'Avg. duration');
+ &jqplot_histograph($graphid++, 'mostfrequent_graph_'.$rank, $graph_data{count}, $graph_data{duration}, 'Queries', 'Avg. duration');
my $users_involved = '';
if (scalar keys %{$normalyzed_info{$k}{users}} > 0) {
my %graph_data = ();
foreach my $h ("00" .. "23") {
foreach my $rd (@histo_avgs) {
- $graph_data{count} .= "['$h:$rd'," . (int($hourly_count{"$h:$rd"}/$days) || 0) . "],";
+ $graph_data{count} .= "['$h:$rd'," . ($hourly_count{"$h:$rd"} || 0) . "],";
$graph_data{duration} .= "['$h:$rd'," . (int($hourly_duration{"$h:$rd"} / ($hourly_count{"$h:$rd"} || 1)) || 0) . "],";
}
}
%hourly_duration = ();
my $query_histo =
- &jqplot_histograph($graphid++, 'normalizedslowest_graph_'.$rank, $graph_data{count}, $graph_data{duration}, 'Avg. queries', 'Avg. duration');
+ &jqplot_histograph($graphid++, 'normalizedslowest_graph_'.$rank, $graph_data{count}, $graph_data{duration}, 'Queries', 'Avg. duration');
my $users_involved = '';
if (scalar keys %{$normalyzed_info{$k}{users}} > 0) {
sub print_log_level
{
my %infos = ();
+ my $ret = 0;
# Some messages have seen their log level change during log parsing.
# Set the real log level count back
next if (!$error_info{$k}{count});
if ($error_info{$k}{count} > 1) {
for (my $i = 0 ; $i <= $#{$error_info{$k}{date}} ; $i++) {
- if ( ($error_info{$k}{error}[$i] =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (database system was)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (recovery has paused)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (skipping analyze of)/LOG: $1/)
- || ($error_info{$k}{error}[$i] =~ s/ERROR: (using stale statistics)/LOG: $1/)
- )
- {
+ ($error_info{$k}{error}[$i], $ret) = &revert_log_level($error_info{$k}{error}[$i]);
+ if ($ret) {
$logs_type{ERROR}--;
$logs_type{LOG}++;
}
}
} else {
- if ( ($error_info{$k}{error}[0] =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (database system was)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (recovery has paused)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (skipping analyze of)/LOG: $1/)
- || ($error_info{$k}{error}[0] =~ s/ERROR: (using stale statistics)/LOG: $1/)
- )
- {
+ ($error_info{$k}{error}[0], $ret) = &revert_log_level($error_info{$k}{error}[0]);
+ if ($ret) {
$logs_type{ERROR}--;
$logs_type{LOG}++;
}
foreach my $k (sort {$error_info{$b}{count} <=> $error_info{$a}{count}} keys %error_info) {
next if (!$error_info{$k}{count});
my $count = &comma_numbers($error_info{$k}{count});
- my $msg = $k;
- $msg =~ s/ERROR: (parameter "[^"]+" changed to)/LOG: $1/;
- $msg =~ s/ERROR: (database system was)/LOG: $1/;
- $msg =~ s/ERROR: (recovery has paused)/LOG: $1/;
- $msg =~ s/ERROR: (sending cancel to blocking autovacuum)/LOG: $1/;
- $msg =~ s/ERROR: (skipping analyze of)/LOG: $1/;
- $msg =~ s/ERROR: (using stale statistics)/LOG: $1/;
+ my ($msg, $ret) = &revert_log_level($k);
my $error_level_class = 'text-error';
if ($msg =~ /^WARNING: /) {
$error_level_class = 'text-warning';
my %graph_data = ();
foreach my $h ("00" .. "23") {
foreach my $rd (@histo_avgs) {
- $graph_data{count} .= "['$h:$rd'," . (int($hourly_count{"$h:$rd"}/$days) || 0) . "],";
+ $graph_data{count} .= "['$h:$rd'," . ($hourly_count{"$h:$rd"} || 0) . "],";
}
}
$graph_data{count} =~ s/,$//;
%hourly_count = ();
my $error_histo =
- &jqplot_histograph($graphid++, 'error_graph_'.$rank, $graph_data{count}, '', 'Avg. events', '');
+ &jqplot_histograph($graphid++, 'error_graph_'.$rank, $graph_data{count}, '', 'Events', '');
# Escape HTML code in error message
$msg = &escape_html($msg);
my %graph_data = ();
foreach my $h ("00" .. "23") {
foreach my $rd (@histo_avgs) {
- $graph_data{count} .= "['$h:$rd'," . (int($hourly_count{"$h:$rd"}/$days) || 0) . "],";
+ $graph_data{count} .= "['$h:$rd'," . ($hourly_count{"$h:$rd"} || 0) . "],";
}
}
$graph_data{count} =~ s/,$//;
%hourly_count = ();
my $error_histo =
- &jqplot_histograph($graphid++, 'pgberror_graph_'.$rank, $graph_data{count}, '', 'Avg. events', '');
+ &jqplot_histograph($graphid++, 'pgberror_graph_'.$rank, $graph_data{count}, '', 'Events', '');
# Escape HTML code in error message
$msg = &escape_html($msg);
my %graph_data = ();
foreach my $h ("00" .. "23") {
foreach my $rd (@histo_avgs) {
- $graph_data{count} .= "['$h:$rd'," . (int($hourly_count{"$h:$rd"}/$days) || 0) . "],";
+ $graph_data{count} .= "['$h:$rd'," . ($hourly_count{"$h:$rd"} || 0) . "],";
}
}
$graph_data{count} =~ s/,$//;
# Force some LOG messages to be ERROR messages so that they will appear
# in the event/error/warning messages report.
if ($prefix_vars{'t_loglevel'} eq 'LOG') {
- if ($prefix_vars{'t_query'} =~ /parameter "[^"]+" changed to "[^"]+"/) {
- $prefix_vars{'t_loglevel'} = 'ERROR';
- } elsif ($prefix_vars{'t_query'} =~ /database system was/) {
- $prefix_vars{'t_loglevel'} = 'ERROR';
- } elsif ($prefix_vars{'t_query'} =~ /recovery has paused/) {
- $prefix_vars{'t_loglevel'} = 'ERROR';
- } elsif ($prefix_vars{'t_query'} =~ /ending cancel to blocking autovacuum/) {
- $prefix_vars{'t_loglevel'} = 'ERROR';
- } elsif ($prefix_vars{'t_query'} =~ /skipping analyze of/) {
- $prefix_vars{'t_loglevel'} = 'ERROR';
- } elsif ($prefix_vars{'t_query'} =~ /using stale statistics/) {
- $prefix_vars{'t_loglevel'} = 'ERROR';
- }
+
+ $prefix_vars{'t_loglevel'} = 'ERROR' if (&change_log_level($prefix_vars{'t_query'}));
} elsif (($prefix_vars{'t_loglevel'} eq 'ERROR') && !$error_only) {
<div id="$divid" class="jqplot-graph histo-graph"><blockquote><b>NO DATASET</b></blockquote></div>
};
}
- $legend1 ||= 'Avg. queries';
+ $legend1 ||= 'Queries';
my $y2decl = '';
my $y2vals = '';
if ($data2) {