diff --git a/centreon/common/cisco/standard/snmp/mode/memory.pm b/centreon/common/cisco/standard/snmp/mode/memory.pm index 6b5449d9d..254757dbe 100644 --- a/centreon/common/cisco/standard/snmp/mode/memory.pm +++ b/centreon/common/cisco/standard/snmp/mode/memory.pm @@ -263,7 +263,7 @@ sub check_memory_enhanced_pool { instances => [keys %$physical_array], instance_regexp => '^(.*)$' ); - $snmp_result = $self->{snmp}->get_leef(nothing_quit => 1); + $snmp_result = $self->{snmp}->get_leef(); foreach (keys %{$self->{memory}}) { if (defined($snmp_result->{ $oid_entPhysicalName . '.' . $self->{memory}->{$_}->{physical_index} })) { $self->{memory}->{$_}->{display} = diff --git a/database/mysql/dbi.pm b/database/mysql/dbi.pm new file mode 100644 index 000000000..43e5bd944 --- /dev/null +++ b/database/mysql/dbi.pm @@ -0,0 +1,41 @@ +# +# Copyright 2019 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package database::mysql::dbi; + +use base qw(centreon::plugins::dbi); + +use strict; +use warnings; + +sub set_version { + my ($self) = @_; + + $self->{version} = $self->{instance}->get_info(18); # SQL_DBMS_VER + # MariaDB: 5.5.5-10.1.36-MariaDB + if ($self->{version} =~ /^(.*.)-(.*?)-MariaDB/i) { + $self->{version} = $1; + $self->{mariadb_version} = $2; + } +} + +1; + +__END__ diff --git a/database/mysql/mode/threadsconnected.pm b/database/mysql/mode/threadsconnected.pm index d0c4a7243..4189a35bf 100644 --- a/database/mysql/mode/threadsconnected.pm +++ b/database/mysql/mode/threadsconnected.pm @@ -84,15 +84,35 @@ sub manage_selection { $self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x')."); $self->{output}->option_exit(); } - - $options{sql}->query(query => q{ - SELECT 'max_connections' as name, @@GLOBAL.max_connections as value - UNION - SELECT VARIABLE_NAME as name, VARIABLE_VALUE as value fROM information_schema.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' - }); + my $infos = {}; - while (my ($name, $value) = $options{sql}->fetchrow_array()) { - $infos->{lc($name)} = $value; + if ($options{sql}->is_version_minimum(version => '5.7.6')) { + $options{sql}->query(query => q{ + SELECT 'max_connections' as name, @@GLOBAL.max_connections as value + UNION + SELECT VARIABLE_NAME as name, VARIABLE_VALUE as value FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Threads_connected' + }); + while (my ($name, $value) = $options{sql}->fetchrow_array()) { + $infos->{lc($name)} = $value; + } + } elsif ($options{sql}->is_version_minimum(version => '5.1.12')) { + $options{sql}->query(query => q{ + SELECT 'max_connections' as name, @@GLOBAL.max_connections as value + UNION + SELECT VARIABLE_NAME as name, VARIABLE_VALUE as value FROM information_schema.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' + }); + while (my ($name, $value) = $options{sql}->fetchrow_array()) { + $infos->{lc($name)} = $value; + } + } else { + $options{sql}->query(query => q{SELECT 'max_connections' as name, @@GLOBAL.max_connections as value}); + if (my ($name, $value) = $options{sql}->fetchrow_array()) { + $infos->{lc($name)} = $value + } + $options{sql}->query(query => q{SHOW /*!50000 global */ STATUS LIKE 'Threads_connected'}); + if (my ($name, $value) = $options{sql}->fetchrow_array()) { + $infos->{lc($name)} = $value + } } if (scalar(keys %$infos) == 0) { diff --git a/database/mysql/plugin.pm b/database/mysql/plugin.pm index fdd234d85..deb108a89 100644 --- a/database/mysql/plugin.pm +++ b/database/mysql/plugin.pm @@ -32,24 +32,25 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'connection-time' => 'centreon::common::protocols::sql::mode::connectiontime', - 'databases-size' => 'database::mysql::mode::databasessize', - 'innodb-bufferpool-hitrate' => 'database::mysql::mode::innodbbufferpoolhitrate', - 'long-queries' => 'database::mysql::mode::longqueries', - 'myisam-keycache-hitrate' => 'database::mysql::mode::myisamkeycachehitrate', - 'open-files' => 'database::mysql::mode::openfiles', - 'qcache-hitrate' => 'database::mysql::mode::qcachehitrate', - 'queries' => 'database::mysql::mode::queries', - 'replication-master-slave' => 'database::mysql::mode::replicationmasterslave', - 'replication-master-master' => 'database::mysql::mode::replicationmastermaster', - 'slow-queries' => 'database::mysql::mode::slowqueries', - 'sql' => 'centreon::common::protocols::sql::mode::sql', - 'sql-string' => 'centreon::common::protocols::sql::mode::sqlstring', - 'tables-size' => 'database::mysql::mode::tablessize', - 'threads-connected' => 'database::mysql::mode::threadsconnected', - 'uptime' => 'database::mysql::mode::uptime', - ); - + 'connection-time' => 'centreon::common::protocols::sql::mode::connectiontime', + 'databases-size' => 'database::mysql::mode::databasessize', + 'innodb-bufferpool-hitrate' => 'database::mysql::mode::innodbbufferpoolhitrate', + 'long-queries' => 'database::mysql::mode::longqueries', + 'myisam-keycache-hitrate' => 'database::mysql::mode::myisamkeycachehitrate', + 'open-files' => 'database::mysql::mode::openfiles', + 'qcache-hitrate' => 'database::mysql::mode::qcachehitrate', + 'queries' => 'database::mysql::mode::queries', + 'replication-master-slave' => 'database::mysql::mode::replicationmasterslave', + 'replication-master-master' => 'database::mysql::mode::replicationmastermaster', + 'slow-queries' => 'database::mysql::mode::slowqueries', + 'sql' => 'centreon::common::protocols::sql::mode::sql', + 'sql-string' => 'centreon::common::protocols::sql::mode::sqlstring', + 'tables-size' => 'database::mysql::mode::tablessize', + 'threads-connected' => 'database::mysql::mode::threadsconnected', + 'uptime' => 'database::mysql::mode::uptime', + ); + + $self->{sql_modes}{dbi} = 'database::mysql::dbi'; $self->{sql_modes}{mysqlcmd} = 'database::mysql::mysqlcmd'; return $self;