minor change mysql
This commit is contained in:
parent
e32d675115
commit
683b95e770
|
@ -81,15 +81,13 @@ sub prefix_table_output {
|
|||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
# $options{sql} = sqlmode object
|
||||
$self->{sql} = $options{sql};
|
||||
$self->{sql}->connect();
|
||||
|
||||
$self->{sql}->query(query => "SELECT table_schema AS DB, table_name AS NAME, ROUND(data_length + index_length)
|
||||
FROM information_schema.TABLES");
|
||||
my $result = $self->{sql}->fetchall_arrayref();
|
||||
$options{sql}->connect();
|
||||
$options{sql}->query(query => "SELECT table_schema AS DB, table_name AS NAME, ROUND(data_length + index_length)
|
||||
FROM information_schema.TABLES");
|
||||
my $result = $options{sql}->fetchall_arrayref();
|
||||
|
||||
if (!($self->{sql}->is_version_minimum(version => '5'))) {
|
||||
if (!($options{sql}->is_version_minimum(version => '5'))) {
|
||||
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -101,12 +99,12 @@ sub manage_selection {
|
|||
next if (!defined($$row[2]));
|
||||
if (defined($self->{option_results}->{filter_table}) && $self->{option_results}->{filter_table} ne '' &&
|
||||
$$row[1] !~ /$self->{option_results}->{filter_table}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1);
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_db}) && $self->{option_results}->{filter_db} ne '' &&
|
||||
$$row[0] !~ /$self->{option_results}->{filter_db}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1);
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $$row[0].'.'.$$row[1] . "': no matching filter.", debug => 1);
|
||||
next
|
||||
}
|
||||
$self->{table}->{$$row[0].'.'.$$row[1]} = { size => $$row[2], display => $$row[0].'.'.$$row[1] };
|
||||
|
|
|
@ -56,26 +56,21 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{sql} = sqlmode object
|
||||
$self->{sql} = $options{sql};
|
||||
|
||||
$self->{sql}->connect();
|
||||
$options{sql}->connect();
|
||||
|
||||
if (!($self->{sql}->is_version_minimum(version => '5'))) {
|
||||
if (!($options{sql}->is_version_minimum(version => '5'))) {
|
||||
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{sql}->query(query => q{SHOW /*!50000 global */ STATUS LIKE 'Threads_connected'});
|
||||
my ($dummy, $result) = $self->{sql}->fetchrow_array();
|
||||
if (!defined($result)) {
|
||||
$options{sql}->query(query => q{SHOW /*!50000 global */ STATUS LIKE 'Threads_connected'});
|
||||
my ($name, $value) = $options{sql}->fetchrow_array();
|
||||
if (!defined($value)) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot get number of open connections.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
my $value = $result;
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("%d client connection threads", $value)
|
||||
|
|
|
@ -58,24 +58,19 @@ sub check_options {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{sql} = sqlmode object
|
||||
$self->{sql} = $options{sql};
|
||||
|
||||
$self->{sql}->connect();
|
||||
|
||||
if (!($self->{sql}->is_version_minimum(version => '5'))) {
|
||||
$options{sql}->connect();
|
||||
if (!($options{sql}->is_version_minimum(version => '5'))) {
|
||||
$self->{output}->add_option_msg(short_msg => "MySQL version '" . $self->{sql}->{version} . "' is not supported (need version >= '5.x').");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{sql}->query(query => q{SHOW /*!50000 global */ STATUS LIKE 'Uptime'});
|
||||
my ($dummy, $result) = $self->{sql}->fetchrow_array();
|
||||
if (!defined($result)) {
|
||||
$options{sql}->query(query => q{SHOW /*!50000 global */ STATUS LIKE 'Uptime'});
|
||||
my ($name, $value) = $options{sql}->fetchrow_array();
|
||||
if (!defined($value)) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot get uptime.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $value = $result;
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my $msg = sprintf("database is up since %d days", floor($value / 86400));
|
||||
|
|
|
@ -44,13 +44,11 @@ sub new {
|
|||
'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',
|
||||
'tables-size' => 'database::mysql::mode::tablessize',
|
||||
'tables-count' => 'database::mysql::mode::tablescount',
|
||||
'open-tables' => 'database::mysql::mode::opentables',
|
||||
'sql-string' => 'centreon::common::protocols::sql::mode::sqlstring',
|
||||
);
|
||||
);
|
||||
|
||||
$self->{sql_modes}{mysqlcmd} = 'database::mysql::mysqlcmd';
|
||||
|
||||
|
|
Loading…
Reference in New Issue