From: Darold Gilles Date: Wed, 29 Aug 2012 07:42:26 +0000 (+0200) Subject: Add report of configuration parameter changes into the errors report and change error... X-Git-Tag: v3.2~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e353c0138d58d6a432241f200ae927eb4734dea;p=pgbadger Add report of configuration parameter changes into the errors report and change errors report by events report to handle important messages that are not errors. --- diff --git a/pgbadger b/pgbadger index 116bee0..60e3766 100755 --- a/pgbadger +++ b/pgbadger @@ -229,7 +229,7 @@ unlink($outfile) if (-e $outfile); # -w and --disable-error can't go together if ($error_only && $disable_error) { - die "FATAL: please choose between no error report and reporting errors only.\n"; + die "FATAL: please choose between no event report and reporting events only.\n"; } # Set default search pattern for database and user name in log_line_prefix @@ -708,7 +708,7 @@ Options: -u | --dbuser username : only report what concern the given user -v | --verbose : enable verbose or debug mode. Disabled by default. -V | --version : show pgBadger version and exit. - -w | --watch-mode : only report errors just like logwatch could do. + -w | --watch-mode : only report events/errors just like logwatch could do. -x | --extension : output format. Values: text or html. Default: html -z | --zcat exec_path : set the full path to the zcat program. Use it if zcat is not on your path or you want to use gzcat. @@ -940,8 +940,8 @@ Last query: $overall_stat{'last_query'} my $fmt_errors = &comma_numbers($overall_stat{'errors_number'}) || 0; my $fmt_unique_error = &comma_numbers(scalar keys %{$overall_stat{'unique_normalized_errors'}}) || 0; print $fh qq{ -Number of errors: $fmt_errors -Number of unique normalized errors: $fmt_unique_error +Number of events: $fmt_errors +Number of unique normalized events: $fmt_unique_error }; } if ($tempfile_info{count}) { @@ -1209,16 +1209,22 @@ Log start from $first_log_date to $last_log_date sub show_error_as_text { - print $fh "\n- Most frequent errors (N) ---------------------------------------------\n\n"; + print $fh "\n- Most frequent events (N) ---------------------------------------------\n\n"; my $idx = 1; foreach my $k (sort {$error_info{$b}{count} <=> $error_info{$a}{count}} keys %error_info) { next if (!$error_info{$k}{count}); last if ($idx > $top); if ($error_info{$k}{count} > 1) { - print $fh "$idx) " . &comma_numbers($error_info{$k}{count}) . " - $k\n"; + my $msg = $k; + $msg =~ s/HINT: (parameter "[^"]+" changed to)/LOG: $1/; + print $fh "$idx) " . &comma_numbers($error_info{$k}{count}) . " - $msg\n"; print $fh "--\n"; my $j = 1; for (my $i = 0 ; $i <= $#{$error_info{$k}{date}} ; $i++) { + if ($error_info{$k}{error}[$i] =~ s/HINT: (parameter "[^"]+" changed to)/LOG: $1/) { + $logs_type{HINT}--; + $logs_type{LOG}++; + } print $fh "\t- Example $j: $error_info{$k}{date}[$i] - $error_info{$k}{error}[$i]\n"; print $fh "\t\tDetail: $error_info{$k}{detail}[$i]\n" if ($error_info{$k}{detail}[$i]); print $fh "\t\tContext: $error_info{$k}{context}[$i]\n" if ($error_info{$k}{context}[$i]); @@ -1247,6 +1253,7 @@ sub show_error_as_text } print $fh "Logs type Count Percentage\n"; foreach my $d (sort keys %logs_type) { + next if (!$logs_type{$d}); print $fh "$d\t\t", &comma_numbers($logs_type{$d}), "\t", sprintf("%0.2f", ($logs_type{$d} * 100) / $total_logs), "%\n"; } } @@ -1529,7 +1536,7 @@ EOF } } if (!$disable_error) { - print $fh qq{Most frequent errors (N) | }; + print $fh qq{Most frequent events (N) | }; print $fh qq{Logs per type}; } print $fh "\n"; @@ -1591,7 +1598,7 @@ qq{Slowest queries
  • Most frequent errors (N)
  • \n"; + print $fh "
  • Most frequent events (N)
  • \n"; print $fh qq{
  • Logs per type
  • \n}; } print $fh qq{ @@ -1657,8 +1664,8 @@ sub dump_as_html my $fmt_errors = &comma_numbers($overall_stat{'errors_number'}) || 0; my $fmt_unique_error = &comma_numbers(scalar keys %{$overall_stat{'unique_normalized_errors'}}) || 0; print $fh qq{ -
  • Number of errors: $fmt_errors
  • -
  • Number of unique normalized errors: $fmt_unique_error
  • +
  • Number of events: $fmt_errors
  • +
  • Number of unique normalized events: $fmt_unique_error