dbd oracle segfault with new version. Disconnect properly fix the issue

This commit is contained in:
garnier-quentin 2019-05-21 09:02:01 +02:00
parent 013da46f75
commit 2c0dfe5844
3 changed files with 18 additions and 18 deletions

View File

@ -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',

View File

@ -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,

View File

@ -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();