Fix mySQL Partitioning
This commit is contained in:
parent
da2c18192a
commit
c91cbcaa13
|
@ -37,10 +37,11 @@ package apps::centreon::mysql::plugin;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use base qw(centreon::plugins::script_simple);
|
use base qw(centreon::plugins::script_sql);
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
# $options->{options} = options object
|
# $options->{options} = options object
|
||||||
|
@ -50,16 +51,60 @@ sub new {
|
||||||
'partitioning' => 'apps::centreon::mysql::mode::partitioning',
|
'partitioning' => 'apps::centreon::mysql::mode::partitioning',
|
||||||
'pollerdelay' => 'apps::centreon::mysql::mode::pollerdelay',
|
'pollerdelay' => 'apps::centreon::mysql::mode::pollerdelay',
|
||||||
);
|
);
|
||||||
|
$self->{sql_modes}{mysqlcmd} = 'database::mysql::mysqlcmd';
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub init {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{options}->add_options(
|
||||||
|
arguments => {
|
||||||
|
'host:s@' => { name => 'db_host' },
|
||||||
|
'port:s@' => { name => 'db_port' },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$self->{options}->parse_options();
|
||||||
|
my $options_result = $self->{options}->get_options();
|
||||||
|
$self->{options}->clean();
|
||||||
|
|
||||||
|
if (defined($options_result->{db_host})) {
|
||||||
|
@{$self->{sqldefault}->{dbi}} = ();
|
||||||
|
@{$self->{sqldefault}->{mysqlcmd}} = ();
|
||||||
|
for (my $i = 0; $i < scalar(@{$options_result->{db_host}}); $i++) {
|
||||||
|
$self->{sqldefault}->{dbi}[$i] = { data_source => 'mysql:host=' . $options_result->{db_host}[$i] };
|
||||||
|
$self->{sqldefault}->{mysqlcmd}[$i] = { host => $options_result->{db_host}[$i] };
|
||||||
|
if (defined($options_result->{db_port}[$i])) {
|
||||||
|
$self->{sqldefault}->{dbi}[$i]->{data_source} .= ';port=' . $options_result->{db_port}[$i];
|
||||||
|
$self->{sqldefault}->{mysqlcmd}[$i]->{port} = $options_result->{db_port}[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
=head1 PLUGIN DESCRIPTION
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
Specific Centreon Indicators.
|
Check MySQL Server.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
You can use following options or options from 'sqlmode' directly.
|
||||||
|
|
||||||
|
=item B<--host>
|
||||||
|
|
||||||
|
Hostname to query.
|
||||||
|
|
||||||
|
=item B<--port>
|
||||||
|
|
||||||
|
Database Server Port.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
Loading…
Reference in New Issue