last;
}
- # Jump to the last line parsed if required
- next if (!&check_incremental_position($prefix_vars{'t_timestamp'}, join(',', @$row)));
-
# Store the current timestamp of the log line
&store_current_timestamp($prefix_vars{'t_timestamp'});
+ # Jump to the last line parsed if required
+ next if (!&check_incremental_position($prefix_vars{'t_timestamp'}, join(',', @$row)));
+
# Set query parameters as global variables
$prefix_vars{'t_dbuser'} = $row->[1] || '';
$prefix_vars{'t_dbname'} = $row->[2] || '';
last;
}
+ # Store the current timestamp of the log line
+ &store_current_timestamp($prefix_vars{'t_timestamp'});
+
# Jump to the last line parsed if required
next if (!&check_incremental_position($prefix_vars{'t_timestamp'}, $line));
$cur_pid = $prefix_vars{'t_pid'};
$goon = 1;
- # Store the current timestamp of the log line
- &store_current_timestamp($prefix_vars{'t_timestamp'});
-
# Extract information from log line prefix
if (!$log_line_prefix) {
&parse_log_prefix($prefix_vars{'t_logprefix'});
last;
}
+ # Store the current timestamp of the log line
+ &store_current_timestamp($prefix_vars{'t_timestamp'});
+
# Jump to the last line parsed if required
next if (!&check_incremental_position($prefix_vars{'t_timestamp'}, $line));
$cur_pid = $prefix_vars{'t_pid'};
- # Store the current timestamp of the log line
- &store_current_timestamp($prefix_vars{'t_timestamp'});
-
# Extract information from log line prefix
if (!$log_line_prefix) {
&parse_log_prefix($prefix_vars{'t_logprefix'});
};
# Overall statistics
- my $fmt_unique = &comma_numbers(scalar keys %normalyzed_info);
- my $fmt_queries = &comma_numbers($overall_stat{'queries_number'});
+ my $fmt_unique = &comma_numbers(scalar keys %normalyzed_info) || 0;
+ my $fmt_queries = &comma_numbers($overall_stat{'queries_number'}) || 0;
my $fmt_duration = &convert_time($overall_stat{'queries_duration'}) || 0;
+ $overall_stat{'first_query_ts'} ||= '-';
+ $overall_stat{'last_query_ts'} ||= '-';
print $fh qq{
- Overall statistics ---------------------------------------------------
last;
}
if (!$disable_error) {
- my $fmt_errors = &comma_numbers($overall_stat{'errors_number'});
- my $fmt_unique_error = &comma_numbers(scalar keys %{$overall_stat{'unique_normalized_errors'}});
+ 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 events: $fmt_errors
Number of unique normalized events: $fmt_unique_error
sub print_overall_statistics
{
- my $fmt_unique = &comma_numbers(scalar keys %normalyzed_info);
- my $fmt_queries = &comma_numbers($overall_stat{'queries_number'});
+ my $fmt_unique = &comma_numbers(scalar keys %normalyzed_info) || 0;
+ my $fmt_queries = &comma_numbers($overall_stat{'queries_number'}) || 0;
my $fmt_duration = &convert_time($overall_stat{'queries_duration'}) || 0;
+ $overall_stat{'first_query_ts'} ||= '-';
+ $overall_stat{'last_query_ts'} ||= '-';
print $fh qq{
<div class="reports">
<h2 id="OverallStatsReport">Overall statistics <a href="#top" title="Back to top">^</a></h2>
last;
}
if (!$disable_error) {
- my $fmt_errors = &comma_numbers($overall_stat{'errors_number'});
- my $fmt_unique_error = &comma_numbers(scalar keys %{$overall_stat{'unique_normalized_errors'}});
+ 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{
<li>Number of events: $fmt_errors</li>
<li>Number of unique normalized events: $fmt_unique_error</li>
{
my $totala = 0;
foreach my $a (@SQL_ACTION) {
- $overall_stat{$a} ||= 0;
$totala += $overall_stat{$a};
}
- if (!$totala) {
- print $fh qq{
+ return if (!$totala);
+
+ print $fh qq{
<h2 id="QueriesByTypeReport">Queries by type <a href="#top" title="Back to top">^</a></h2>
<table>
<tr><td width="500" align="left" valign="top">
<th>Percentage</th>
</tr>
};
- my $total = $overall_stat{'queries_number'} || 1;
+ my $total = $overall_stat{'queries_number'} || 1;
- my $r = 0;
- foreach my $a (@SQL_ACTION) {
- print $fh "<tr class=\"row$r\"><td>$a</td><td class=\"right\">", &comma_numbers($overall_stat{'$a'}),
- "</td><td class=\"right\">", sprintf("%0.2f", ($overall_stat{$a} * 100) / $total), "%</td></tr>\n";
- ($r > 0) ? $r = 0 : $r = 1;
- }
- print $fh "<tr class=\"row0\"><td>OTHERS</td><td class=\"right\">", &comma_numbers($total - $totala),
- "</td><td class=\"right\">", sprintf("%0.2f", (($total - $totala) * 100) / $total), "%</td></tr>\n"
- if (($total - $totala) > 0);
- print $fh "</table></td><td width=\"500\" align=\"center\" valign=\"top\">\n";
+ my $r = 0;
+ foreach my $a (@SQL_ACTION) {
+ print $fh "<tr class=\"row$r\"><td>$a</td><td class=\"right\">", &comma_numbers($overall_stat{'$a'}),
+ "</td><td class=\"right\">", sprintf("%0.2f", ($overall_stat{$a} * 100) / $total), "%</td></tr>\n";
+ ($r > 0) ? $r = 0 : $r = 1;
+ }
+ print $fh "<tr class=\"row0\"><td>OTHERS</td><td class=\"right\">", &comma_numbers($total - $totala),
+ "</td><td class=\"right\">", sprintf("%0.2f", (($total - $totala) * 100) / $total), "%</td></tr>\n"
+ if (($total - $totala) > 0);
+ print $fh "</table></td><td width=\"500\" align=\"center\" valign=\"top\">\n";
- if ($graph) {
- my %data = ();
- foreach my $t (@SQL_ACTION) {
- if ((($overall_stat{$t} * 100) / $total) > $pie_percentage_limit) {
- $data{$t} = $overall_stat{$t} || 0;
- } else {
- $data{"Sum types < $pie_percentage_limit%"} += $overall_stat{$t} || 0;
- }
- }
- if (((($total - $totala) * 100) / $total) > $pie_percentage_limit) {
- $data{'Others'} = $total - $totala;
+ if ($graph) {
+ my %data = ();
+ foreach my $t (@SQL_ACTION) {
+ if ((($overall_stat{$t} * 100) / $total) > $pie_percentage_limit) {
+ $data{$t} = $overall_stat{$t} || 0;
} else {
- $data{"Sum types < $pie_percentage_limit%"} += $total - $totala;
+ $data{"Sum types < $pie_percentage_limit%"} += $overall_stat{$t} || 0;
}
- &flotr2_piegraph(22, 'queriesbytype_graph', 'Type of queries', %data);
}
- print $fh "</td></tr></table>\n";
+ if (((($total - $totala) * 100) / $total) > $pie_percentage_limit) {
+ $data{'Others'} = $total - $totala;
+ } else {
+ $data{"Sum types < $pie_percentage_limit%"} += $total - $totala;
+ }
+ &flotr2_piegraph(22, 'queriesbytype_graph', 'Type of queries', %data);
}
+ print $fh "</td></tr></table>\n";
}
sub print_request_report