in reply to Creating a perl script for database monitoring

foreach $data ( @$data) {

That doesn't look right. You have the same variable in the iterator as in the list over which you are iterating. At best, that's confusing. Eg. instead:

foreach my $thisone (@$data) {

You might also consider some more meaningful name than $data but that's purely a stylistic tip.

Replies are listed 'Best First'.
Re^2: Creating a perl script for database monitoring
by Jeylox (Initiate) on Apr 08, 2016 at 13:09 UTC
    Thank you for the quick reply :) I have too use the ->plugin_exit( each time to return a code (0=OK,1=UNKNOWN,2=CRITICAL,3=WARNING) from the data. If I rename the $data i have uncompiled result.  File attente de datatable CRITICAL - File attente (ARRAY(0x10841e8) ARRAY(0x1084230) ARRAY(0x1084278))

      Thats because when you change foreach $data ( @$data) { to foreach my $thisone ( @$data) {, you must also change (my $variable1,my $variable2,my $variable3) = @$data; to (my $variable1,my $variable2,my $variable3) = @$thisone; and change check    => $data, to check    => $thisone,

      The docs say "You can specify $value as an array of values and each will be checked against the thresholds." so try without the loop.

      my $data = $sth->fetchall_arrayref(); $sth->finish; my $code_retour = $oracle_connector->check_threshold( check => $data, warning => $oracle_connector->opts->warning, critical => $oracle_connector->opts->critical, ); $oracle_connector->plugin_exit( $code_retour, "File attente (@$data)" +);
      poj

        Without the loop the programm do again unreadable results

        File attente de datatable CRITICAL - File attente (ARRAY(0x10841e8) ARRAY(0x1084230) ARRAY(0x1084278))

        With your instruction my result can be read but there is again the main problem to have result of each line of the sql request, i will think if an idea for not doing the loop