From 70e4e35d28c8e3da64fefbdf2d1cce8ad75426f3 Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Thu, 12 Jul 2018 11:07:26 +0200 Subject: [PATCH] fix postgres databasesize mode, missing empty selection (#1047) --- centreon-plugins/database/postgres/mode/databasesize.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/centreon-plugins/database/postgres/mode/databasesize.pm b/centreon-plugins/database/postgres/mode/databasesize.pm index 56639706d..be8fdf740 100644 --- a/centreon-plugins/database/postgres/mode/databasesize.pm +++ b/centreon-plugins/database/postgres/mode/databasesize.pm @@ -79,6 +79,8 @@ sub manage_selection { my $result = $self->{sql}->fetchall_arrayref(); + $self->{databases} = {}; + foreach my $row (@$result) { next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' && $$row[0] !~ /$self->{option_results}->{filter_database}/); @@ -86,6 +88,11 @@ sub manage_selection { $self->{databases}->{$$row[0]}->{display} = $$row[0]; $self->{databases}->{$$row[0]}->{size} = $$row[1]; } + + if (scalar(keys %{$self->{databases}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No databases found'); + $self->{output}->option_exit(); + } } 1;