fix mysql for threads connected
This commit is contained in:
parent
d820b9319e
commit
92361ea897
|
@ -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__
|
|
@ -86,7 +86,16 @@ sub manage_selection {
|
|||
}
|
||||
|
||||
my $infos = {};
|
||||
if ($options{sql}->is_version_minimum(version => '5.1.12')) {
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue