(plugin) apps::centreon::local - mode bamservice make it work (#4242)
This commit is contained in:
parent
c4fe39fa55
commit
c9b5efaa81
|
@ -57,7 +57,16 @@ sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $sql = centreon::plugins::dbi->new(options => $self->{options}, output => $self->{output}, nooptions => 1);
|
my $sql = centreon::plugins::dbi->new(options => $self->{options}, output => $self->{output}, nooptions => 1);
|
||||||
$sql->{data_source} = 'mysql:host=' . $centreon_config->{db_host} . 'port=' . $centreon_config->{db_port};
|
|
||||||
|
my $port = '';
|
||||||
|
if (defined($centreon_config->{db_port})) {
|
||||||
|
$port = ';port=' . $centreon_config->{db_port};
|
||||||
|
} elsif ($centreon_config->{db_host} =~ /:(\d+)$/) {
|
||||||
|
$port = ';port=' . $1;
|
||||||
|
$centreon_config->{db_host} =~ s/:\d+$//;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql->{data_source} = 'mysql:host=' . $centreon_config->{db_host} . $port;
|
||||||
$sql->{username} = $centreon_config->{db_user};
|
$sql->{username} = $centreon_config->{db_user};
|
||||||
$sql->{password} = $centreon_config->{db_passwd};
|
$sql->{password} = $centreon_config->{db_passwd};
|
||||||
$sql->connect();
|
$sql->connect();
|
||||||
|
@ -65,7 +74,7 @@ sub run {
|
||||||
$sql->query(query => "SELECT `name`,`current_level`,`level_w`,`level_c` FROM " . $centreon_config->{centreon_db} .
|
$sql->query(query => "SELECT `name`,`current_level`,`level_w`,`level_c` FROM " . $centreon_config->{centreon_db} .
|
||||||
".`mod_bam` WHERE `ba_id` = '" . $self->{option_results}->{bam_id} . "'"
|
".`mod_bam` WHERE `ba_id` = '" . $self->{option_results}->{bam_id} . "'"
|
||||||
);
|
);
|
||||||
my ($name, $current_level, $level_w, $level_c) = $self->{sql}->fetchrow_array();
|
my ($name, $current_level, $level_w, $level_c) = $sql->fetchrow_array();
|
||||||
if (!defined($current_level)) {
|
if (!defined($current_level)) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot get bam information");
|
$self->{output}->add_option_msg(short_msg => "Cannot get bam information");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
|
Loading…
Reference in New Issue