From ef0d016576b79442c0618b964843f9db40e095c6 Mon Sep 17 00:00:00 2001
From: qgarnier <garnier.quentin@gmail.com>
Date: Mon, 2 Nov 2020 17:25:56 +0100
Subject: [PATCH] fix timeout issue (#2316)

---
 apps/monitoring/alyvix/restapi/custom/api.pm | 2 +-
 centreon/plugins/backend/http/curl.pm        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/apps/monitoring/alyvix/restapi/custom/api.pm b/apps/monitoring/alyvix/restapi/custom/api.pm
index 0b311cfa7..1ea38b2f6 100644
--- a/apps/monitoring/alyvix/restapi/custom/api.pm
+++ b/apps/monitoring/alyvix/restapi/custom/api.pm
@@ -76,7 +76,7 @@ sub check_options {
     $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 80;
     $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http';
     $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/v0/';
-    $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
+    $self->{timeout} = (defined($self->{option_results}->{timeout}) && $self->{option_results}->{timeout} =~ /^(\d+)$/) ? $1 : 30;
     $self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : undef;
     $self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : undef;
     $self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_status} : '%{http_code} < 200 or %{http_code} >= 300';
diff --git a/centreon/plugins/backend/http/curl.pm b/centreon/plugins/backend/http/curl.pm
index 76510d499..7c091e62f 100644
--- a/centreon/plugins/backend/http/curl.pm
+++ b/centreon/plugins/backend/http/curl.pm
@@ -301,7 +301,7 @@ sub request {
         $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_VERBOSE'), parameter => 1);
     }
 
-    if (defined($options{request}->{timeout})) {
+    if (defined($options{request}->{timeout}) && $options{request}->{timeout} =~ /\d/) {
         $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_TIMEOUT'), parameter => $options{request}->{timeout});
     }
     if (defined($options{request}->{cookies_file})) {