(plugin) apps::centreon::local - mode bamservice make it work (#4242)

This commit is contained in:
qgarnier 2023-03-01 14:13:16 +00:00 committed by GitHub
parent 2683d38e39
commit 80e31d0672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -57,7 +57,16 @@ sub run {
my ($self, %options) = @_;
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->{password} = $centreon_config->{db_passwd};
$sql->connect();
@ -65,7 +74,7 @@ sub run {
$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} . "'"
);
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)) {
$self->{output}->add_option_msg(short_msg => "Cannot get bam information");
$self->{output}->option_exit();