From e32989dc5c2a6e61d7886e34bc07dbb302901fd9 Mon Sep 17 00:00:00 2001 From: Simon BOMM Date: Wed, 15 Apr 2015 11:04:01 +0200 Subject: [PATCH] Add error catching when there is no partitions --- apps/centreon/mysql/mode/partitioning.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/centreon/mysql/mode/partitioning.pm b/apps/centreon/mysql/mode/partitioning.pm index 8e59ed9fd..3483f6e98 100644 --- a/apps/centreon/mysql/mode/partitioning.pm +++ b/apps/centreon/mysql/mode/partitioning.pm @@ -90,13 +90,18 @@ sub run { $self->{output}->output_add(severity => 'OK', short_msg => sprintf("All partitions are up to date")); - #$self->{option_results}->{retentionforward}--; - foreach my $table (@partitionedTables) { $self->{sql}->query(query => "SELECT TABLE_NAME,PARTITION_NAME FROM information_schema.PARTITIONS WHERE TABLE_NAME='".$table."' ORDER BY PARTITION_NAME DESC LIMIT 1;"); - + my ($tableName, $yyyymmdd) = $self->{sql}->fetchrow_array(); + if (!defined $yyyymmdd) { + $self->{output}->output_add(severity => 'UNKNOWN', + short_msg => sprintf("Couldn't get infos from mysql, is all specified tables have partitions ?")); + $self->{output}->display(); + $self->{output}->exit(); + } + $yyyymmdd =~ s/^.//; $self->{output}->output_add(long_msg => sprintf("Table %s last partition date is %s", $tableName, $yyyymmdd));