centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 273 forks source link

[database::mssql::plugin] --mode=databases-size: returns OK even database not exists #4988

Open joschi99 opened 4 months ago

joschi99 commented 4 months ago

If you are monitor a non existing MS SQL database using the option --filter-database= the plugin returns OK, when you filter for a non existing database. Example:

centreon_plugins.pl --server=<IP>:<PORT> --username=XXX --password=XXX --plugin=database::mssql::plugin --mode=databases-size --filter-database='ThisIsANonExistingDatabase'
OK:

This is a big issue and in this case the plugin should return CRITICAL or UNKNOWN, but not OK.

joschi99 commented 3 months ago

are there any news on this?

lucie-dubrunfaut commented 1 month ago

Hello :)

This is not a voluntarily generated OK in fact the result table is empty but no error is reported (which in itself is a problem I completely agree). At the end of the result parse (line 372) something like this should be added:

if (scalar(keys %{$self->{databases}}) <= 0 && defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '') {
        $self->{output}->add_option_msg(short_msg => "No database matching with filter: ".$self->{option_results}->{filter_database});
        $self->{output}->option_exit();
}

(This is a proposition that I was not able to test it on my own.)