my $max = -1;
my $maxmsg = '?';
+ ## The perf must be added before the add_x, so we defer the settings:
+ my (@addwarn, @addcrit);
+
for my $r (@{ $db->{slurp} }) {
for my $v (values %$r) {
## Do the table first if we haven't seen it
if (! $seenit{"$dbname.$schema.$table"}++) {
my $nicename = perfname("$schema.$table");
- $db->{perf} = "$nicename:${wb}B";
$perf{$wb}{$nicename}++;
my $msg = msg('bloat-table', $dbname, $schema, $table, $tups, $pages, $otta, $bloat, $wb, $ws);
my $ok = 1;
next;
}
if ($critical->($wb, $perbloat)) {
- add_critical $msg;
+ push @addcrit => $msg;
$ok = 0;
}
if ($ok and $warning->($wb, $perbloat)) {
- add_warning $msg;
+ push @addwarn => $msg;
$ok = 0;
}
($max = $wb, $maxmsg = $msg) if $wb > $max and $ok;
## Now the index, if it exists
if ($index ne '?') {
my $nicename = perfname($index);
- $db->{perf} = "$nicename:${iwb}B";
$perf{$iwb}{$nicename}++;
my $msg = msg('bloat-index', $dbname, $index, $irows, $ipages, $iotta, $ibloat, $iwb, $iws);
my $ok = 1;
next;
}
if ($critical->($iwb, $iperbloat)) {
- add_critical $msg;
+ push @addcrit => $msg;
$ok = 0;
}
if ($ok and $warning->($iwb, $iperbloat)) {
- add_warning $msg;
+ push @addwarn => $msg;
$ok = 0;
}
($max = $iwb, $maxmsg = $msg) if $iwb > $max and $ok;
}
}
+ ## Set a sorted limited perf
+ $db->{perf} = '';
+ my $count = 0;
+ PERF: for my $size (sort {$b <=> $a } keys %perf) {
+ for my $name (sort keys %{ $perf{$size} }) {
+ $db->{perf} .= "$name=${size}B ";
+ last PERF if $opt{perflimit} and ++$count >= $opt{perflimit};
+ }
+ }
+
+ ## Now we can set the critical and warning
+ for (@addcrit) {
+ add_critical $_;
+ $db->{perf} = '';
+ }
+ for (@addwarn) {
+ add_warning $_;
+ $db->{perf} = '';
+ }
+
if ($max == -1) {
add_unknown msg('no-match-rel');
}
elsif ($max != -1) {
- ## Show the sorted perf
- $db->{perf} = '';
- for my $size (sort {$b <=> $a } keys %perf) {
- for my $name (sort keys %{ $perf{$size} }) {
- $db->{perf} .= "$name=${size}B ";
- }
- }
add_ok $maxmsg;
}
Exclude "idle in transaction" from the query_time check (bug #43)
+ Fix the perflimit for the bloat action (bug #50)
+
Clean up the custom_query action a bit.
=item B<Version 2.16.0> January 20, 2011