[check_postgres] Problems with check_bloat

Luis Vazquez luis at asterisk.uy
Tue Jul 21 17:20:56 UTC 2015


I'm sorry there was a "bug" in my proposed "bug-fix" below :(
I missed the needed colons when de-referencing the arrayref; so the 
proposed if condition in check_bloat should be:

...
if (!defined($db->{slurp}) || @{$db->{slurp}} == 0) {
add_ok msg('bloat-nomin') unless $MRTG;
         return;
     }
...

Regards,
Luis

El 21/07/15 13:35, Luis Vazquez escribió:
> * The function check_bloat uses two hardcoded variables $MINPAGES and 
> $MINIPAGES that seems to be the minimum pages for a table or an index 
> to be taken into account.
> Playing with those values I've found some code that is really cryptic 
> (and I thing is a bug) when you check the result of the select 
> returned from the run_command() to see if you have an empty result set.
> Here you are using an scalar matching operator 
> (http://mkweb.bcgsc.ca/intranet/perlbook/prog/ch05_02.htm) to check 
> for a non empty value in an array o maps object ($db->{slurp}).
> ** LINE: 3905 **
>    $db = $info->{db}[0];
>
>     if (*$db->{slurp} !~ /\w+/o*) {
>         add_ok msg('bloat-nomin') unless $MRTG;
>         return;
>     }
> The referred message is 'bloat-nomin'=> q{no relations meet the 
> minimum bloat criteria},
>
> When I increase the values of $MINPAGES/$MINIPAGES so there are no 
> results in the select, $db->{slurp} is an empty array reference but 
> the if condition keeps giving false because you are matching against 
> the string representation of the reference, something like: 
> ARRAY(0x24daec0).
>
> I have verified that in the run_command() function you make sure to 
> return an array: $db->{slurp} = \@stuff
> So to check for no results, I think you should instead check for an 
> undefined (to be on the safe side) or an empty array reference with 
> something like this:
> if (!defined(*$db->{slurp}*) || @*$db->{slurp}* == 0) {
>         add_ok msg('bloat-nomin') unless $MRTG;
>         return;
>     }
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.endcrypt.com/pipermail/check_postgres/attachments/20150721/ae68af9c/attachment.html>


More information about the Check_postgres mailing list