dbd oracle segfault with new version. Disconnect properly fix the issue
This commit is contained in:
parent
013da46f75
commit
2c0dfe5844
|
@ -33,8 +33,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
|
||||||
"warning:s" => { name => 'warning', },
|
"warning:s" => { name => 'warning', },
|
||||||
"critical:s" => { name => 'critical', },
|
"critical:s" => { name => 'critical', },
|
||||||
});
|
});
|
||||||
|
@ -64,6 +63,7 @@ sub run {
|
||||||
my $now = Time::HiRes::time();
|
my $now = Time::HiRes::time();
|
||||||
my ($exit, $msg_error) = $self->{sql}->connect(dontquit => 1);
|
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) {
|
if ($exit == -1) {
|
||||||
$self->{output}->output_add(severity => 'CRITICAL',
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
|
|
@ -31,8 +31,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
|
||||||
"sql-statement:s" => { name => 'sql_statement', },
|
"sql-statement:s" => { name => 'sql_statement', },
|
||||||
"format:s" => { name => 'format', default => 'SQL statement result : %i.'},
|
"format:s" => { name => 'format', default => 'SQL statement result : %i.'},
|
||||||
"perfdata-unit:s" => { name => 'perfdata_unit', default => ''},
|
"perfdata-unit:s" => { name => 'perfdata_unit', default => ''},
|
||||||
|
@ -70,7 +69,6 @@ sub check_options {
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
# $options{sql} = sqlmode object
|
|
||||||
$self->{sql} = $options{sql};
|
$self->{sql} = $options{sql};
|
||||||
|
|
||||||
my $query = $self->{option_results}->{sql_statement};
|
my $query = $self->{option_results}->{sql_statement};
|
||||||
|
@ -78,6 +76,7 @@ sub run {
|
||||||
$self->{sql}->connect();
|
$self->{sql}->connect();
|
||||||
$self->{sql}->query(query => $query);
|
$self->{sql}->query(query => $query);
|
||||||
my $value = $self->{sql}->fetchrow_array();
|
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' } ]);
|
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,
|
$self->{output}->output_add(severity => $exit_code,
|
||||||
|
|
|
@ -159,6 +159,7 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{sql}->disconnect();
|
||||||
if (scalar(keys %{$self->{rows}}) <= 0) {
|
if (scalar(keys %{$self->{rows}}) <= 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => $self->{option_results}->{empty_sql_string});
|
$self->{output}->add_option_msg(short_msg => $self->{option_results}->{empty_sql_string});
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
|
Loading…
Reference in New Issue