From 2ab2b52d6b3410ca3c8f1deb40d32cd42df5e81c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 24 Nov 2020 15:41:14 +0100 Subject: [PATCH] enhance curl --- apps/cisco/dnac/restapi/custom/api.pm | 7 ++++--- centreon/plugins/backend/http/curl.pm | 2 +- network/cisco/firepower/fmc/restapi/custom/api.pm | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/cisco/dnac/restapi/custom/api.pm b/apps/cisco/dnac/restapi/custom/api.pm index d481981a4..fb14e1757 100644 --- a/apps/cisco/dnac/restapi/custom/api.pm +++ b/apps/cisco/dnac/restapi/custom/api.pm @@ -77,7 +77,7 @@ sub check_options { $self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443; $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; - $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 50; $self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300'; $self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : ''; $self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : ''; @@ -165,6 +165,7 @@ sub authenticate { if ($has_cache_file == 0 || !defined($session_token)) { my ($content) = $self->{http}->request( method => 'POST', + query_form_post => '', url_path => '/dna/system/api/v1/auth/token', credentials => 1, basic => 1, @@ -218,7 +219,7 @@ sub request_api { get_param => $options{get_param}, unknown_status => $self->{unknown_http_status}, warning_status => $self->{warning_http_status}, - critical_status => $self->{critical_http_status} + critical_status => $self->{critical_http_status}, ); } @@ -267,7 +268,7 @@ Set password. =item B<--timeout> -Set timeout in seconds (Default: 10). +Set timeout in seconds (Default: 50). =back diff --git a/centreon/plugins/backend/http/curl.pm b/centreon/plugins/backend/http/curl.pm index 7c091e62f..5c412fb34 100644 --- a/centreon/plugins/backend/http/curl.pm +++ b/centreon/plugins/backend/http/curl.pm @@ -167,7 +167,7 @@ sub set_method { if ($options{content_type_forced} == 1) { $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_POSTFIELDS'), parameter => $options{request}->{query_form_post}) - if (defined($options{request}->{query_form_post}) && $options{request}->{query_form_post} ne ''); + if (defined($options{request}->{query_form_post})); } elsif (defined($options{request}->{post_params})) { my $uri_post = URI->new(); $uri_post->query_form($options{request}->{post_params}); diff --git a/network/cisco/firepower/fmc/restapi/custom/api.pm b/network/cisco/firepower/fmc/restapi/custom/api.pm index c08298307..9b45c17c2 100644 --- a/network/cisco/firepower/fmc/restapi/custom/api.pm +++ b/network/cisco/firepower/fmc/restapi/custom/api.pm @@ -165,6 +165,7 @@ sub authenticate { if ($has_cache_file == 0 || !defined($session_token)) { $self->{http}->request( method => 'POST', + query_form_post => '', url_path => '/api/fmc_platform/v1/auth/generatetoken', credentials => 1, basic => 1,