{
($extension) ? push(@outfiles, 'out.' . $extension) : push(@outfiles, 'out.html');
map { s/\.text/.txt/; } @outfiles;
-
+
}
# Set the default extension and output format, load JSON Perl module if required
}
}
}
- # Now removed the corresponding days
+ # Now removed the corresponding days
foreach my $y (sort { $a <=> $b } @dyears) {
unless(opendir(DIR, "$outdir/$y")) {
localdie("Error: can't opendir $outdir/$y: $!");
# Auto detect log format for proper parsing
my $fmt = autodetect_format($f);
- # Set regex to parse the log file
+ # Set regex to parse the log file
$fmt = set_parser_regex($fmt);
if (($fmt ne 'pgbouncer') && ($saved_last_line{current_pos} > 0))
&restore_log_type_count();
foreach $outfile (@outfiles)
- {
+ {
($current_out_file, $extens) = &set_output_extension($outfile, $extension);
$extens = $dft_extens if ($current_out_file eq '-' && $dft_extens);
If you have a pg_dump at 23:00 and 13:00 each day during half an hour, you can
use pgBadger as follow to exclude these period from the report:
- pgbadger --exclude-time "2013-09-.* (23|13):.*" postgresql.log
+ pgbadger --exclude-time "2013-09-.* (23|13):.*" postgresql.log
This will help avoid having COPY statements, as generated by pg_dump, on top of
the list of slowest queries. You can also use --exclude-appname "pg_dump" to
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- $pgbadger_logo
+ $pgbadger_logo
<div class="pull-right"> <a title="PostgreSQL Log Analyzer" href="" id="pgbadger-brand" class="navbar-brand" data-original-title="PostgreSQL Log Analyzer">$local_title</a></div>
</div>
</div>
print STDERR "reset CSV parser\n";
$csv->SetDiag(0);
} else {
- $cursize = $totalsize;
+ $cursize = $totalsize;
}
}
}
while ($str =~ s/\\r\\n/\n/gs) {};
while ($str =~ s/([^\\])\\r/$1\n/gs) {};
while ($str =~ s/([^\\])\\n/$1\n/gs) {};
-
+
return $str;
}
if ($1 > $autovacuum_info{peak}{system_usage}{elapsed}) {
$autovacuum_info{peak}{system_usage}{elapsed} = $1;
$autovacuum_info{peak}{system_usage}{table} = $cur_info{$cur_pid}{vacuum};
- $autovacuum_info{peak}{system_usage}{date} =
+ $autovacuum_info{peak}{system_usage}{date} =
"$cur_info{$cur_pid}{year}-$cur_info{$cur_pid}{month}-$cur_info{$cur_pid}{day} " .
"$cur_info{$cur_pid}{hour}:$cur_info{$cur_pid}{min}:$cur_info{$cur_pid}{sec}";
}
if ($iscompressed) {
close($lfile);
return (1, "log file is compressed");
-
+
}
my ($gsec, $gmin, $ghour, $gmday, $gmon, $gyear, $gwday, $gyday, $gisdst) = localtime(time);
my $bpath = $incr_date;
$bpath =~ s/\-/\//g;
- # Mark this directory as needing a reindex
+ # Mark this directory as needing a reindex
if (open(my $out, '>>' , "$last_parsed.tmp")) {
flock($out, 2) || return 1;
print $out "$incr_date\n";
# Remove extra space, new line and tab characters by a single space
$orig_query =~ s/\s+/ /gs;
- # Removed start of transaction
+ # Removed start of transaction
if ($orig_query !~ /^\s*begin\s*;\s*$/) {
$orig_query =~ s/^\s*begin\s*;\s*//gs
}
$milliseconds =~ s/\.\d+//;
}
$milliseconds =~ s/^[0]+// if ($milliseconds !~ /\./);
-
+
$time = $days . $hours . $minutes . $seconds . $milliseconds;
$time = '0ms' if ($time eq '');
print $fh "\t- Example $j: ", &convert_time($d), " - $db - ", $normalyzed_info{$k}{samples}{$d}{query}, "\n";
$j++;
}
- }
+ }
$idx++;
}
@top_temporary = ();
print $fh "\t- Example $j: ", &convert_time($d), " - $db - ", $normalyzed_info{$k}{samples}{$d}{query}, "\n";
$j++;
}
- }
+ }
$idx++;
}
@top_cancelled = ();
<li><a href="#checkpoints-buffers">Checkpoints buffers</a></li>
<li><a href="#checkpoints-files">Checkpoints files</a></li>
<li><a href="#checkpoints-distance">Checkpoints distance</a></li>
- <li><a href="#checkpoint-activity">Checkpoint activity</a></li>
+ <li><a href="#checkpoint-activity">Checkpoint activity</a></li>
</ul>
</li>
};
};
}
print $fh qq{
- </ul>
+ </ul>
</li>
};
}
$sqlstate_report
<li class="divider"></li>
<li><a href="#most-frequent-errors-events">Most frequent errors/events</a></li>
- </ul>
+ </ul>
</li>
};
}
<!-- Modal -->
<div class="modal fade" id="pgbadgerModal">
<div class="modal-dialog">
-
+
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
-
+
</div>
</div>
@{$all_query_duration{'WRITE'}}= sort{ $a <=> $b } (@{$all_query_duration{'INSERT'}},@{$all_query_duration{'UPDATE'}},@{$all_query_duration{'DELETE'}},@{$all_query_duration{'COPY FROM'}});
$cur_period_info{'WRITE'}{$lp}{percentileindex} = int(@{$all_query_duration{'WRITE'}} * $lp / 100) ;
$cur_period_info{'WRITE'}{$lp}{percentile} = $all_query_duration{'WRITE'}[$cur_period_info{'WRITE'}{$lp}{percentileindex}];
- $percentile{'WRITE'}{$lp} = &convert_time($cur_period_info{'WRITE'}{$lp}{percentile});
+ $percentile{'WRITE'}{$lp} = &convert_time($cur_period_info{'WRITE'}{$lp}{percentile});
}
$queries .= qq{
<tr>
</thead>
<tbody>$queries
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="general-activity-select-queries">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$select_queries
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="general-activity-write-queries">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$write_queries
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="general-activity-prepared-queries">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$prepared_queries
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="general-activity-connections">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$connections
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="general-activity-sessions">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$sessions
</tbody>
- </table>
+ </table>
</div>
</div> <!-- end of div tab-content -->
<span class="pull-right">↑ <small><a href="#general-activity" class="">Back to the top of the <em>General Activity</em> table</a></small></span>
<div class="well key-figures">
<ul>
<li><span class="figure">$query_peak queries/s</span> <span class="figure-label">Query Peak</span></li>
- <li><span class="figure">$query_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$query_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$select_peak queries/s</span> <span class="figure-label">Query Peak</span></li>
- <li><span class="figure">$select_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$select_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$write_peak queries/s</span> <span class="figure-label">Query Peak</span></li>
- <li><span class="figure">$write_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$write_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$request_peak queries/s</span> <span class="figure-label">Request Peak</span></li>
- <li><span class="figure">$request_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$request_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$inbytes_peak Bytes/s</span> <span class="figure-label">In Bytes Peak</span></li>
- <li><span class="figure">$inbytes_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$inbytes_peak_date</span> <span class="figure-label">Date</span></li>
<li><span class="figure">$outbytes_peak Bytes/s</span> <span class="figure-label">Out Bytes Peak</span></li>
- <li><span class="figure">$outbytes_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$outbytes_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$avgduration_peak</span> <span class="figure-label">Average Duration Peak</span></li>
- <li><span class="figure">$avgduration_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$avgduration_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
# Average duration per minute
$graph_data{query4} .= "[$t, " . sprintf("%.3f", ($q_dataavg{duration}{"$rd"} || 0) / ($q_dataavg{count}{"$rd"} || 1)) . "],";
}
- if (scalar keys %c_dataavg) {
+ if (scalar keys %c_dataavg) {
# Average connections per minute
$graph_data{conn_avg} .= "[$t, " . int(($c_dataavg{average}{"$rd"} || 0) / (60 * $avg_minutes)) . "],";
# Max connections per minute
# Min connections per minute
$graph_data{conn_min} .= "[$t, " . ($c_dataavg{min}{"$rd"} || 0) . "],";
}
- if (scalar keys %s_dataavg) {
+ if (scalar keys %s_dataavg) {
# Average connections per minute
$graph_data{sess_avg} .= "[$t, " . int(($s_dataavg{average}{"$rd"} || 0) / (60 * $avg_minutes)) . "],";
# Max connections per minute
# Min connections per minute
$graph_data{sess_min} .= "[$t, " . ($s_dataavg{min}{"$rd"} || 0) . "],";
}
- if (!$disable_query && (scalar keys %a_dataavg > 0)) {
+ if (!$disable_query && (scalar keys %a_dataavg > 0)) {
foreach my $action (@SQL_ACTION) {
next if ($select_only && ($action ne 'SELECT'));
}
}
}
- if (!$disable_query && (scalar keys %p_dataavg> 0)) {
+ if (!$disable_query && (scalar keys %p_dataavg> 0)) {
$graph_data{prepare} .= "[$t, " . ($p_dataavg{prepare}{"$rd"} || 0) . "],";
$graph_data{execute} .= "[$t, " . ($p_dataavg{execute}{"$rd"} || 0) . "],";
$graph_data{ratio_bind_prepare} .= "[$t, " . sprintf("%.2f", ($p_dataavg{execute}{"$rd"} || 0) / ($p_dataavg{prepare}{"$rd"} || 1)) . "],";
next if ($t < $t_min);
last if ($t > $t_max);
- if (scalar keys %c_dataavg) {
+ if (scalar keys %c_dataavg) {
# Average connections per minute
$graph_data{conn_avg} .= "[$t, " . int(($c_dataavg{average}{"$rd"} || 0) / (60 * $avg_minutes)) . "],";
# Max connections per minute
# Min connections per minute
$graph_data{conn_min} .= "[$t, " . ($c_dataavg{min}{"$rd"} || 0) . "],";
}
- if (scalar keys %s_dataavg) {
+ if (scalar keys %s_dataavg) {
# Average connections per minute
$graph_data{sess_avg} .= "[$t, " . int(($s_dataavg{average}{"$rd"} || 0) / (60 * $avg_minutes)) . "],";
# Max connections per minute
<div class="well key-figures">
<ul>
<li><span class="figure">$connection_peak connections</span> <span class="figure-label">Connection Peak</span></li>
- <li><span class="figure">$connection_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$connection_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$connection_peak connections</span> <span class="figure-label">Connection Peak</span></li>
- <li><span class="figure">$connection_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$connection_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_user[0]</span> <span class="figure-label">Main User</span></li>
- <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$conn_user_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_user[0]</span> <span class="figure-label">Main User</span></li>
- <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$conn_user_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_host[0]</span> <span class="figure-label">Main host with $main_host[1] connections</span></li>
- <li><span class="figure">$total_count</span> <span class="figure-label">Total connections</span></li>
+ <li><span class="figure">$total_count</span> <span class="figure-label">Total connections</span></li>
</ul>
</div>
</div>
<tbody>
$conn_host_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_host[0]</span> <span class="figure-label">Main host with $main_host[1] connections</span></li>
- <li><span class="figure">$total_count</span> <span class="figure-label">Total connections</span></li>
+ <li><span class="figure">$total_count</span> <span class="figure-label">Total connections</span></li>
</ul>
</div>
</div>
<tbody>
$conn_host_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_database[0]</span> <span class="figure-label">Main Database</span></li>
- <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$conn_database_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_database[0]</span> <span class="figure-label">Main Database</span></li>
- <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count connections</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$conn_database_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$session_peak sessions</span> <span class="figure-label">Session Peak</span></li>
- <li><span class="figure">$session_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$session_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$session_peak sessions</span> <span class="figure-label">Session Peak</span></li>
- <li><span class="figure">$session_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$session_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
<tbody>
$histogram_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$histogram_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_user[0]</span> <span class="figure-label">Main User</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_user_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_user[0]</span> <span class="figure-label">Main User</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_user_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_host[0]</span> <span class="figure-label">Main Host</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_host_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_host[0]</span> <span class="figure-label">Main Host</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_host_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_app[0]</span> <span class="figure-label">Main Host</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_app_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_database[0]</span> <span class="figure-label">Main Database</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_database_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_database[0]</span> <span class="figure-label">Main Database</span></li>
- <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count sessions</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$sess_database_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
}
}
# Checkpoint buffers and files
- $drawn_graphs{checkpointwritebuffers_graph} =
+ $drawn_graphs{checkpointwritebuffers_graph} =
&jqplot_linegraph($graphid++, 'checkpointwritebuffers_graph', $graph_data{wbuffer}, '', '',
'Checkpoint write buffers (' . $avg_minutes . ' minutes period)',
'Buffers', 'Write buffers', '', ''
<div class="well key-figures">
<ul>
<li><span class="figure">$checkpoint_wbuffer_peak buffers</span> <span class="figure-label">Checkpoint Peak</span></li>
- <li><span class="figure">$checkpoint_wbuffer_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$checkpoint_wbuffer_peak_date</span> <span class="figure-label">Date</span></li>
<li><span class="figure">$overall_checkpoint{checkpoint_write} seconds</span> <span class="figure-label">Highest write time</span></li>
<li><span class="figure">$overall_checkpoint{checkpoint_sync} seconds</span> <span class="figure-label">Sync time</span></li>
</ul>
<div class="well key-figures">
<ul>
<li><span class="figure">$checkpoint_distance_peak Mo</span> <span class="figure-label">Distance Peak</span></li>
- <li><span class="figure">$checkpoint_distance_peak_date</span> <span class="figure-label">Date</span></li>
+ <li><span class="figure">$checkpoint_distance_peak_date</span> <span class="figure-label">Date</span></li>
</ul>
</div>
</div>
</thead>
<tbody>$buffers
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="checkpoint-activity-files">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$files
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="checkpoint-activity-warnings">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$warnings
</tbody>
- </table>
+ </table>
</div>
<div class="tab-pane" id="checkpoint-activity-distance">
<table class="table table-striped table-hover table-condensed">
</thead>
<tbody>$distance
</tbody>
- </table>
- </div>
+ </table>
+ </div>
</div> <!-- end of div tab-content -->
<span class="pull-right">↑ <small><a href="#checkpoint-activity" class="">Back to the top of the <em>Checkpoint Activity</em> table</a></small></span>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_analyze[0] ($main_analyze[1])</span> <span class="figure-label">Main table analyzed (database $database)</span></li>
- <li><span class="figure">$total_count analyzes</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count analyzes</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$analyze_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_vacuum[0] ($main_vacuum[1])</span> <span class="figure-label">Main table vacuumed on database $database</span></li>
- <li><span class="figure">$total_count vacuums</span> <span class="figure-label">Total</span></li>
+ <li><span class="figure">$total_count vacuums</span> <span class="figure-label">Total</span></li>
</ul>
</div>
</div>
<tbody>
$vacuum_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$vacuum_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$vacuum_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$locktype_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$querytype_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$query_database_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$query_application_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
$infos{duration}{$d} = $user_info{$d}{duration} || 0;
} else {
$infos{duration}{"Sum duration per users < $pie_percentage_limit%"} += $user_info{$d}{duration} || 0;
- push(@{$small{duration}}, $d);
+ push(@{$small{duration}}, $d);
}
}
if ($#{$small{queries}} == 0) {
}
if ($#{$small{duration}} == 0){
$infos{duration}{$small{duration}[0]} = $infos{duration}{"Sum duration per users < $pie_percentage_limit%"};
- delete $infos{duration}{"Sum duration per users < $pie_percentage_limit%"};
+ delete $infos{duration}{"Sum duration per users < $pie_percentage_limit%"};
}
}
$drawn_graphs{queriesbyuser_graph} = &jqplot_piegraph($graphid++, 'graph_queriesbyuser', 'Queries per user', %{$infos{queries}});
<tbody>
$query_user_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$query_user_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$query_host_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
print $fh qq{
<dt>
<div id="query-c-$rank-$idx" class="sql sql-largesize"><i class="glyphicon icon-copy" title="Click to select query"></i>$query</div>$md5
-
+
</dt>
<pre>$details</pre>
};
</td>
</tr>
};
- }
+ }
$rank++;
}
print $fh qq{
print $fh qq{
<dt>
<div id="query-d-$rank-$idx" class="sql sql-largesize"><i class="glyphicon icon-copy" title="Click to select query"></i>$query</div>$md5
-
+
</dt>
<pre>$details</pre>
};
</td>
</tr>
};
- }
+ }
$rank++;
}
print $fh qq{
<tbody>
$histogram_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
if (scalar keys %{$normalyzed_info{$k}{apps}} > 0) {
$apps_involved = qq{<button type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-target="#time-consuming-queries-app-involved-rank-$rank">App(s) involved</button>};
}
- my $query_histo =
+ my $query_histo =
&jqplot_histograph($graphid++, 'time_consuming_queries_details_'.$rank, $graph_data{count}, $graph_data{duration}, 'Queries', 'Avg. duration');
print $fh qq{
<tbody>
$logtype_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<tbody>
$errorclass_info
</tbody>
- </table>
+ </table>
</div>
</div>
</div>
<div class="well key-figures">
<ul>
<li><span class="figure">$main_error</span> <span class="figure-label">Max number of times the same event was reported</span></li>
- <li><span class="figure">$total</span> <span class="figure-label">Total events found</span></li>
+ <li><span class="figure">$total</span> <span class="figure-label">Total events found</span></li>
</ul>
- </div>
+ </div>
</div>
<div class="col-md-9">
<table class="table table-striped" id="most-frequent-errors-events-table">
</div><!-- end of details collapse -->
};
print $fh qq{
-<p><button type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-target="#most-frequent-errors-events-examples-rank-$rank">Examples</button></p>
+<p><button type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-target="#most-frequent-errors-events-examples-rank-$rank">Examples</button></p>
} if (($sample > 0) && ($#{$error_info{$k}{date}} >= 0));
print $fh qq{
<!-- Examples collapse -->
<div class="well key-figures">
<ul>
<li><span class="figure">$main_error</span> <span class="figure-label">Max number of times the same event was reported</span></li>
- <li><span class="figure">$total</span> <span class="figure-label">Total events found</span></li>
+ <li><span class="figure">$total</span> <span class="figure-label">Total events found</span></li>
</ul>
- </div>
+ </div>
</div>
<div class="col-md-9">
<table class="table table-striped" id="pgbmost-frequent-errors-events-table">
</div><!-- end of details collapse -->
};
print $fh qq{
-<p><button type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-target="#pgbmost-frequent-errors-events-examples-rank-$rank">Examples</button></p>
+<p><button type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-target="#pgbmost-frequent-errors-events-examples-rank-$rank">Examples</button></p>
} if (($sample > 0) && ($#{$pgb_error_info{$k}{date}} >= 0));
print $fh qq{
<!-- Examples collapse -->
<ul>
<li><span class="figure">$main_pool</span> <span class="figure-label">Most used reserved pool</span></li>
<li><span class="figure">$main_pool_val</span> <span class="figure-label">Time used</span></li>
- <li><span class="figure">$total</span> <span class="figure-label">Total time reserved pools was used</span></li>
+ <li><span class="figure">$total</span> <span class="figure-label">Total time reserved pools was used</span></li>
</ul>
- </div>
+ </div>
</div>
<div class="col-md-9">
<table class="table table-striped" id="pgbmost-used-reserved-pool-table">
if ($_overall_stat{'first_log_ts'}) {
$overall_stat{'first_log_ts'} = $_overall_stat{'first_log_ts'}
- if (!$overall_stat{'first_log_ts'} ||
+ if (!$overall_stat{'first_log_ts'} ||
($overall_stat{'first_log_ts'} gt $_overall_stat{'first_log_ts'}));
}
}
$overall_stat{'last_query_ts'} = $_overall_stat{'last_query_ts'}
- if not $overall_stat{'last_query_ts'}
+ if not $overall_stat{'last_query_ts'}
or $overall_stat{'last_query_ts'} lt $_overall_stat{'last_query_ts'};
$overall_stat{errors_number} += $_overall_stat{errors_number};
}
}
for (my $i = 0; $i <= $#{$_error_info{$q}{date}}; $i++) {
- &set_top_error_sample( $q,
- $_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}{detail}[$i],
+ $_error_info{$q}{context}[$i],
$_error_info{$q}{statement}[$i],
- $_error_info{$q}{hint}[$i],
+ $_error_info{$q}{hint}[$i],
$_error_info{$q}{db}[$i],
$_error_info{$q}{user}[$i],
$_error_info{$q}{app}[$i],
}
}
for (my $i = 0; $i <= $#{$_pgb_error_info{$q}{date}}; $i++) {
- &pgb_set_top_error_sample( $q,
- $_pgb_error_info{$q}{date}[$i],
+ &pgb_set_top_error_sample( $q,
+ $_pgb_error_info{$q}{date}[$i],
$_pgb_error_info{$q}{error}[$i],
$_pgb_error_info{$q}{db}[$i],
$_pgb_error_info{$q}{user}[$i],
($_pgb_per_minute_info{$day}{$hour}{$min}{connection}{count} || 0);
$pgb_per_minute_info{$day}{$hour}{$min}{session}{count} +=
($_pgb_per_minute_info{$day}{$hour}{$min}{session}{count} || 0);
- $pgb_per_minute_info{$day}{$hour}{$min}{t_req} +=
+ $pgb_per_minute_info{$day}{$hour}{$min}{t_req} +=
($_pgb_per_minute_info{$day}{$hour}{$min}{t_req} || 0);
- $pgb_per_minute_info{$day}{$hour}{$min}{t_inbytes} +=
+ $pgb_per_minute_info{$day}{$hour}{$min}{t_inbytes} +=
($_pgb_per_minute_info{$day}{$hour}{$min}{t_inbytes} || 0);
- $pgb_per_minute_info{$day}{$hour}{$min}{t_outbytes} +=
+ $pgb_per_minute_info{$day}{$hour}{$min}{t_outbytes} +=
($_pgb_per_minute_info{$day}{$hour}{$min}{t_outbytes} || 0);
- $pgb_per_minute_info{$day}{$hour}{$min}{t_avgduration} +=
+ $pgb_per_minute_info{$day}{$hour}{$min}{t_avgduration} +=
($_pgb_per_minute_info{$day}{$hour}{$min}{t_avgduration} || 0);
}
}
$normalyzed_info{$stmt}{count} += $_normalyzed_info{$stmt}{count};
# Set min / max duration for this query
- if (!exists $normalyzed_info{$stmt}{min} || ($normalyzed_info{$stmt}{min} > $_normalyzed_info{$stmt}{min})) {
+ if (!exists $normalyzed_info{$stmt}{min} || ($normalyzed_info{$stmt}{min} > $_normalyzed_info{$stmt}{min})) {
$normalyzed_info{$stmt}{min} = $_normalyzed_info{$stmt}{min};
}
- if (!exists $normalyzed_info{$stmt}{max} || ($normalyzed_info{$stmt}{max} < $_normalyzed_info{$stmt}{max})) {
+ if (!exists $normalyzed_info{$stmt}{max} || ($normalyzed_info{$stmt}{max} < $_normalyzed_info{$stmt}{max})) {
$normalyzed_info{$stmt}{max} = $_normalyzed_info{$stmt}{max};
}
if (exists $_normalyzed_info{$stmt}{locks}) {
$normalyzed_info{$stmt}{locks}{count} += $_normalyzed_info{$stmt}{locks}{count};
$normalyzed_info{$stmt}{locks}{wait} += $_normalyzed_info{$stmt}{locks}{wait};
- if (!exists $normalyzed_info{$stmt}{locks}{minwait} || ($normalyzed_info{$stmt}{locks}{minwait} > $_normalyzed_info{$stmt}{locks}{minwait})) {
+ if (!exists $normalyzed_info{$stmt}{locks}{minwait} || ($normalyzed_info{$stmt}{locks}{minwait} > $_normalyzed_info{$stmt}{locks}{minwait})) {
$normalyzed_info{$stmt}{locks}{minwait} = $_normalyzed_info{$stmt}{locks}{minwait};
}
- if (!exists $normalyzed_info{$stmt}{locks}{maxwait} || ($normalyzed_info{$stmt}{locks}{maxwait} < $_normalyzed_info{$stmt}{locks}{maxwait})) {
+ if (!exists $normalyzed_info{$stmt}{locks}{maxwait} || ($normalyzed_info{$stmt}{locks}{maxwait} < $_normalyzed_info{$stmt}{locks}{maxwait})) {
$normalyzed_info{$stmt}{locks}{maxwait} = $_normalyzed_info{$stmt}{locks}{maxwait};
}
}
if (exists $_normalyzed_info{$stmt}{tempfiles}) {
$normalyzed_info{$stmt}{tempfiles}{count} += $_normalyzed_info{$stmt}{tempfiles}{count};
$normalyzed_info{$stmt}{tempfiles}{size} += $_normalyzed_info{$stmt}{tempfiles}{size};
- if (!exists $normalyzed_info{$stmt}{tempfiles}{minsize} || ($normalyzed_info{$stmt}{tempfiles}{minsize} > $_normalyzed_info{$stmt}{tempfiles}{minsize})) {
+ if (!exists $normalyzed_info{$stmt}{tempfiles}{minsize} || ($normalyzed_info{$stmt}{tempfiles}{minsize} > $_normalyzed_info{$stmt}{tempfiles}{minsize})) {
$normalyzed_info{$stmt}{tempfiles}{minsize} = $_normalyzed_info{$stmt}{tempfiles}{minsize};
}
- if (!exists $normalyzed_info{$stmt}{tempfiles}{maxsize} || ($normalyzed_info{$stmt}{tempfiles}{maxsize} < $_normalyzed_info{$stmt}{tempfiles}{maxsize})) {
+ if (!exists $normalyzed_info{$stmt}{tempfiles}{maxsize} || ($normalyzed_info{$stmt}{tempfiles}{maxsize} < $_normalyzed_info{$stmt}{tempfiles}{maxsize})) {
$normalyzed_info{$stmt}{tempfiles}{maxsize} = $_normalyzed_info{$stmt}{tempfiles}{maxsize};
}
}
my $fmt = shift;
my $is_log_level = 0;
-
+
my $t_pid = $prefix_vars{'t_pid'};
my $date_part = "$prefix_vars{'t_year'}$prefix_vars{'t_month'}$prefix_vars{'t_day'}";
if ($1 > $autovacuum_info{peak}{system_usage}{elapsed}) {
$autovacuum_info{peak}{system_usage}{elapsed} = $1;
$autovacuum_info{peak}{system_usage}{table} = $cur_info{$t_pid}{vacuum};
- $autovacuum_info{peak}{system_usage}{date} =
+ $autovacuum_info{peak}{system_usage}{date} =
"$prefix_vars{'t_year'}-$prefix_vars{'t_month'}-$prefix_vars{'t_day'} " .
"$prefix_vars{'t_hour'}:$prefix_vars{'t_min'}:$prefix_vars{'t_sec'}";
}
if ($sample > 0) {
my $cur_last_log_timestamp = "$cur_info{$t_pid}{year}-$cur_info{$t_pid}{month}-$cur_info{$t_pid}{day} " .
"$cur_info{$t_pid}{hour}:$cur_info{$t_pid}{min}:$cur_info{$t_pid}{sec}";
- &set_top_error_sample( $normalized_error,
- $cur_last_log_timestamp,
- $cur_info{$t_pid}{query},
+ &set_top_error_sample( $normalized_error,
+ $cur_last_log_timestamp,
+ $cur_info{$t_pid}{query},
$cur_info{$t_pid}{detail},
- $cur_info{$t_pid}{context},
- $cur_info{$t_pid}{statement},
- $cur_info{$t_pid}{hint},
- $cur_info{$t_pid}{dbname},
+ $cur_info{$t_pid}{context},
+ $cur_info{$t_pid}{statement},
+ $cur_info{$t_pid}{hint},
+ $cur_info{$t_pid}{dbname},
$cur_info{$t_pid}{dbuser},
$cur_info{$t_pid}{dbappname},
$cur_info{$t_pid}{dbclient},
return ($fmt, $ident_name);
}
-
+
sub progress_bar
{
my ($got, $total, $width, $char, $queries, $errors) = @_;
$chunks[0] = $saved_pos;
}
}
- # With small files splitting is inefficient
+ # With small files splitting is inefficient
if ($totalsize <= 16777216) {
return ($chunks[0], $totalsize);
}
} else {
$weekNumber = POSIX::strftime("%W", 1, 1, 1, $day, $month - 1, $year - 1900);
}
-
+
return sprintf("%02d", $weekNumber+1);
}
sub IsLeapYear
{
return ((($_[0] & 3) == 0) && (($_[0] % 100 != 0) || ($_[0] % 400 == 0)));
-}
+}
####
# Display calendar
$str .= "<tr>$week" . join('', @currow) . "</tr>\n";
@currow = ('','','','','','','');
}
- }
+ }
if ( ($wd != 6) || ($currow[0] ne '') ) {
$week = sprintf("%02d", $wn);
if (-e "$outdir/$year/week-$week/index.html") {
while ($tmp_str =~ s/\s+AS\s+([^\s]+)\s+//is) {
my $code_sep = quotemeta($1);
foreach my $k (@{ $self->{ 'keywords' } }) {
- last if ($code_sep =~ s/\b$k$//i);
+ last if ($code_sep =~ s/\b$k$//i);
}
if ($tmp_str =~ /\s+$code_sep[\s;]+/) {
while ( $temp_content[$j] =~ s/($code_sep.*$code_sep)/CODEPART${i}CODEPART/s) {
elsif ($token =~ /^(RETURN|RETURNS)$/i) {
$self->{ '_is_in_index' } = 0;
}
-
+
####
# Mark statements that use string_agg() or group_concat() function
# as statement that can have an ORDER BY clause inside the call to
$self->{ '_is_in_type' }-- if ($self->{ '_is_in_type' });
$self->_new_line if ($self->{ '_current_sql_stmt' } ne 'INSERT'
and !$self->{ '_is_in_function' }
- and (defined $self->_next_token
+ and (defined $self->_next_token
and $self->_next_token =~ /^(SELECT|WITH)$/i)
and $last ne ')'
);
{
$self->_new_line;
$self->_over if (!$self->{ '_is_in_join' });
- }
+ }
$self->_add_token( $token );
}
}
elsif ($token =~ /^\\\S/)
{
- # treat everything starting with a \ and at least one character as psql meta command.
+ # treat everything starting with a \ and at least one character as psql meta command.
$self->_add_token( $token );
$self->_new_line;
}
if ( (!defined($last_token) || $last_token ne '(') && $token ne ')' && ($token !~ /^::/) ) {
$self->{ 'content' } .= $sp if ($token ne ')'
&& defined($last_token)
- && $last_token ne '::'
+ && $last_token ne '::'
&& ($token ne '(' || !$self->_is_function( $last_token ) || $self->{ '_is_in_type' })
);
$self->{ 'content' } .= $sp if (!defined($last_token) && $token);
# First load it all as "my" variables, to make it simpler to modify/map/grep/add
# Afterwards, when everything is ready, put it in $self->{'dict'}->{...}
- my @pg_keywords = map { uc } qw(
+ my @pg_keywords = map { uc } qw(
ADD AFTER ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC ASYMMETRIC AUTHORIZATION AUTO_INCREMENT
BACKWARD BEFORE BEGIN BERNOULLI BETWEEN BINARY BOTH BY BY CACHE CASCADE CASE CAST CHECK CHECKPOINT
CLOSE CLUSTER COLLATE COLLATION COLUMN COMMENT COMMIT COMMITTED CONCURRENTLY CONFLICT CONSTRAINT
}
}
- # Replace any COMMENT constant between single quote
+ # Replace any COMMENT constant between single quote
while ($$str =~ s/IS\s+('[^;]+);/IS TEXTVALUE$idx;/s) {
$self->{dynamic_code}{$idx} = $1;
$idx++;