From 2c0dfe58445c1be5d4dfa680ea30eecfacee84cf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 21 May 2019 09:02:01 +0200 Subject: [PATCH] dbd oracle segfault with new version. Disconnect properly fix the issue --- .../protocols/sql/mode/connectiontime.pm | 12 +++++----- centreon/common/protocols/sql/mode/sql.pm | 23 +++++++++---------- .../common/protocols/sql/mode/sqlstring.pm | 1 + 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/centreon/common/protocols/sql/mode/connectiontime.pm b/centreon/common/protocols/sql/mode/connectiontime.pm index 517226cc2..c16758939 100644 --- a/centreon/common/protocols/sql/mode/connectiontime.pm +++ b/centreon/common/protocols/sql/mode/connectiontime.pm @@ -33,11 +33,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - }); + $options{options}->add_options(arguments => { + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', }, + }); return $self; } @@ -63,7 +62,8 @@ sub run { my $now = Time::HiRes::time(); my ($exit, $msg_error) = $self->{sql}->connect(dontquit => 1); - my $now2 = Time::HiRes::time(); + my $now2 = Time::HiRes::time(); + $self->{sql}->disconnect(); if ($exit == -1) { $self->{output}->output_add(severity => 'CRITICAL', diff --git a/centreon/common/protocols/sql/mode/sql.pm b/centreon/common/protocols/sql/mode/sql.pm index 80964fc5b..1a562124c 100644 --- a/centreon/common/protocols/sql/mode/sql.pm +++ b/centreon/common/protocols/sql/mode/sql.pm @@ -31,17 +31,16 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "sql-statement:s" => { name => 'sql_statement', }, - "format:s" => { name => 'format', default => 'SQL statement result : %i.'}, - "perfdata-unit:s" => { name => 'perfdata_unit', default => ''}, - "perfdata-name:s" => { name => 'perfdata_name', default => 'value'}, - "perfdata-min:s" => { name => 'perfdata_min', default => ''}, - "perfdata-max:s" => { name => 'perfdata_max', default => ''}, - "warning:s" => { name => 'warning', }, - "critical:s" => { name => 'critical', }, - }); + $options{options}->add_options(arguments => { + "sql-statement:s" => { name => 'sql_statement', }, + "format:s" => { name => 'format', default => 'SQL statement result : %i.'}, + "perfdata-unit:s" => { name => 'perfdata_unit', default => ''}, + "perfdata-name:s" => { name => 'perfdata_name', default => 'value'}, + "perfdata-min:s" => { name => 'perfdata_min', default => ''}, + "perfdata-max:s" => { name => 'perfdata_max', default => ''}, + "warning:s" => { name => 'warning', }, + "critical:s" => { name => 'critical', }, + }); return $self; } @@ -70,7 +69,6 @@ sub check_options { sub run { my ($self, %options) = @_; - # $options{sql} = sqlmode object $self->{sql} = $options{sql}; my $query = $self->{option_results}->{sql_statement}; @@ -78,6 +76,7 @@ sub run { $self->{sql}->connect(); $self->{sql}->query(query => $query); my $value = $self->{sql}->fetchrow_array(); + $self->{sql}->disconnect(); 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, diff --git a/centreon/common/protocols/sql/mode/sqlstring.pm b/centreon/common/protocols/sql/mode/sqlstring.pm index d43436b2e..d673a2414 100644 --- a/centreon/common/protocols/sql/mode/sqlstring.pm +++ b/centreon/common/protocols/sql/mode/sqlstring.pm @@ -159,6 +159,7 @@ sub manage_selection { } } + $self->{sql}->disconnect(); if (scalar(keys %{$self->{rows}}) <= 0) { $self->{output}->add_option_msg(short_msg => $self->{option_results}->{empty_sql_string}); $self->{output}->option_exit();