diff --git a/apps/apache/serverstatus/mode/cpuload.pm b/apps/apache/serverstatus/mode/cpuload.pm index 076a0795a..1b0a0b331 100644 --- a/apps/apache/serverstatus/mode/cpuload.pm +++ b/apps/apache/serverstatus/mode/cpuload.pm @@ -32,24 +32,21 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "header:s@" => { name => 'header' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "header:s@" => { name => 'header' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -118,10 +115,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -154,10 +147,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--header> Set HTTP headers (Multiple option) diff --git a/apps/apache/serverstatus/mode/requests.pm b/apps/apache/serverstatus/mode/requests.pm index 9a409d489..8fa141e58 100644 --- a/apps/apache/serverstatus/mode/requests.pm +++ b/apps/apache/serverstatus/mode/requests.pm @@ -33,28 +33,25 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "header:s@" => { name => 'header' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "warning-bytes:s" => { name => 'warning_bytes' }, - "critical-bytes:s" => { name => 'critical_bytes' }, - "warning-access:s" => { name => 'warning_access' }, - "critical-access:s" => { name => 'critical_access' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "header:s@" => { name => 'header' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "warning-bytes:s" => { name => 'warning_bytes' }, + "critical-bytes:s" => { name => 'critical_bytes' }, + "warning-access:s" => { name => 'warning_access' }, + "critical-access:s" => { name => 'critical_access' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); $self->{statefile_value} = centreon::plugins::statefile->new(%options); return $self; } @@ -207,10 +204,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -243,10 +236,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--header> Set HTTP headers (Multiple option) diff --git a/apps/apache/serverstatus/mode/responsetime.pm b/apps/apache/serverstatus/mode/responsetime.pm index f7f425b57..a10cdfd20 100644 --- a/apps/apache/serverstatus/mode/responsetime.pm +++ b/apps/apache/serverstatus/mode/responsetime.pm @@ -33,27 +33,24 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "header:s@" => { name => 'header' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "header:s@" => { name => 'header' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + "unknown-status:s" => { name => 'unknown_status', default => '' }, + "warning-status:s" => { name => 'warning_status' }, + "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -142,18 +139,10 @@ Specify this option if you access server-status page over hidden basic authentic (Use with --credentials) -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--header> Set HTTP headers (Multiple option) diff --git a/apps/apache/serverstatus/mode/slotstates.pm b/apps/apache/serverstatus/mode/slotstates.pm index 6bf032970..8b48ccf32 100644 --- a/apps/apache/serverstatus/mode/slotstates.pm +++ b/apps/apache/serverstatus/mode/slotstates.pm @@ -194,24 +194,21 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "header:s@" => { name => 'header' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "units:s" => { name => 'units', default => '%' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "header:s@" => { name => 'header' }, + "timeout:s" => { name => 'timeout' }, + "units:s" => { name => 'units', default => '%' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); foreach my $key (('global')) { foreach (keys %{$maps_counters->{$key}}) { @@ -331,10 +328,6 @@ IP Address or FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -367,10 +360,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--header> Set HTTP headers (Multiple option) diff --git a/apps/apache/serverstatus/mode/workers.pm b/apps/apache/serverstatus/mode/workers.pm index 9527b8c60..f94da1217 100644 --- a/apps/apache/serverstatus/mode/workers.pm +++ b/apps/apache/serverstatus/mode/workers.pm @@ -32,24 +32,21 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "header:s@" => { name => 'header' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/server-status/?auto" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "header:s@" => { name => 'header' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -122,10 +119,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol to use http or https, http is default @@ -158,10 +151,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--header> Set HTTP headers (Multiple option) @@ -176,4 +165,4 @@ Critical Threshold (%) of busy workers =back -=cut \ No newline at end of file +=cut diff --git a/apps/bind9/web/custom/api.pm b/apps/bind9/web/custom/api.pm index 8722b125c..aab1dea65 100644 --- a/apps/bind9/web/custom/api.pm +++ b/apps/bind9/web/custom/api.pm @@ -45,9 +45,7 @@ sub new { "port:s" => { name => 'port' }, "proto:s" => { name => 'proto' }, "url-path:s" => { name => 'url_path' }, - "proxyurl:s" => { name => 'proxyurl' }, "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, "unknown-status:s" => { name => 'unknown_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, "warning-status:s" => { name => 'warning_status' }, "critical-status:s" => { name => 'critical_status' }, @@ -57,7 +55,7 @@ sub new { $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -97,7 +95,6 @@ sub check_options { $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8080; $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/'; $self->{unknown_status} = (defined($self->{option_results}->{unknown_status})) ? $self->{option_results}->{unknown_status} : undef; $self->{warning_status} = (defined($self->{option_results}->{warning_status})) ? $self->{option_results}->{warning_status} : undef; @@ -124,7 +121,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{url_path} = $self->{url_path}; $self->{option_results}->{unknown_status} = $self->{unknown_status}; $self->{option_results}->{warning_status} = $self->{warning_status}; @@ -160,8 +156,7 @@ sub request { $self->settings(); my $response = $self->{http}->request(); - my $headers = $self->{http}->get_header(); - my $content_type = $headers->header('Content-Type'); + my ($content_type) = $self->{http}->get_header(name => 'Content-Type'); if (!defined($content_type) || $content_type !~ /(xml|json)/i) { $self->{output}->add_option_msg(short_msg => "content-type not set"); $self->{output}->option_exit(); @@ -444,18 +439,10 @@ Specify https if needed (Default: 'http') Statistics Channel API Path (Default: '/'). -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/bluemind/mode/incoming.pm b/apps/bluemind/mode/incoming.pm index b0601660f..3a59faae7 100644 --- a/apps/bluemind/mode/incoming.pm +++ b/apps/bluemind/mode/incoming.pm @@ -34,24 +34,21 @@ sub new { bless $self, $class; $self->{version} = '1.1'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8086'}, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/db" }, - "database:s" => { name => 'database' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8086'}, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/db" }, + "database:s" => { name => 'database' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); $self->{statefile_value} = centreon::plugins::statefile->new(%options); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -198,18 +195,10 @@ Specify username for API authentification Specify password for API authentification -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for failure incoming mails diff --git a/apps/checkmyws/mode/status.pm b/apps/checkmyws/mode/status.pm index 4fa6eba63..eb2d057d5 100644 --- a/apps/checkmyws/mode/status.pm +++ b/apps/checkmyws/mode/status.pm @@ -42,20 +42,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'api.checkmy.ws'}, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto', default => "https" }, - "urlpath:s" => { name => 'url_path', default => "/api/status" }, - "proxyurl:s" => { name => 'proxyurl' }, - "uid:s" => { name => 'uid' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'api.checkmy.ws'}, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto', default => "https" }, + "urlpath:s" => { name => 'url_path', default => "/api/status" }, + "uid:s" => { name => 'uid' }, + "timeout:s" => { name => 'timeout' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -194,10 +191,6 @@ Checkmyws api host (Default: 'api.checkmy.ws') Port used by checkmyws -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed (Default: 'https') @@ -206,18 +199,10 @@ Specify https if needed (Default: 'https') Set path to get checkmyws information (Default: '/api/status') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--uid> ID for checkmyws API diff --git a/apps/cisco/cms/restapi/custom/xmlapi.pm b/apps/cisco/cms/restapi/custom/xmlapi.pm index 4e9a1f263..d4f04f132 100644 --- a/apps/cisco/cms/restapi/custom/xmlapi.pm +++ b/apps/cisco/cms/restapi/custom/xmlapi.pm @@ -40,24 +40,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "url-path:s" => { name => 'url_path' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "url-path:s" => { name => 'url_path' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'XMLAPI OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -94,8 +91,6 @@ sub check_options { $self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/api/v1'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; if (!defined($self->{option_results}->{username}) || $self->{option_results}->{username} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --username option."); @@ -120,7 +115,6 @@ sub build_options_for_httplib { $self->{option_results}->{password} = $self->{password}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; $self->{option_results}->{unknown_status} = ''; @@ -158,9 +152,8 @@ sub get_endpoint { $self->settings; my $content = $self->{http}->request(url_path => $self->{url_path} . $options{method}); - my $response = $self->{http}->get_response(); - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { my $xml_result; eval { $xml_result = XMLin($content); @@ -230,18 +223,10 @@ Set API username Set API password -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL options if needed (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/cisco/ise/restapi/custom/xmlapi.pm b/apps/cisco/ise/restapi/custom/xmlapi.pm index c796830ff..df7da19e3 100644 --- a/apps/cisco/ise/restapi/custom/xmlapi.pm +++ b/apps/cisco/ise/restapi/custom/xmlapi.pm @@ -40,24 +40,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "url-path:s" => { name => 'url_path' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "url-path:s" => { name => 'url_path' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'XMLAPI OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -94,8 +91,6 @@ sub check_options { $self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/admin/API/mnt'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; if (!defined($self->{option_results}->{username}) || $self->{option_results}->{username} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --username option."); @@ -120,7 +115,6 @@ sub build_options_for_httplib { $self->{option_results}->{password} = $self->{password}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -157,9 +151,8 @@ sub get_endpoint { $self->settings; my $content = $self->{http}->request(url_path => $self->{url_path} . $options{category}); - my $response = $self->{http}->get_response(); - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { my $xml_result; eval { $xml_result = XMLin($content); @@ -229,18 +222,10 @@ Set API username Set API password -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL options if needed (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/elasticsearch/restapi/custom/api.pm b/apps/elasticsearch/restapi/custom/api.pm index d58f82672..389f6b76b 100644 --- a/apps/elasticsearch/restapi/custom/api.pm +++ b/apps/elasticsearch/restapi/custom/api.pm @@ -40,23 +40,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -93,7 +90,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -114,7 +110,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -187,18 +182,10 @@ Elasticsearch username. Elasticsearch password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/github/mode/commits.pm b/apps/github/mode/commits.pm index 253228685..86b0a4ad8 100644 --- a/apps/github/mode/commits.pm +++ b/apps/github/mode/commits.pm @@ -35,19 +35,16 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'api.github.com' }, - "port:s" => { name => 'port', default => '443'}, - "proto:s" => { name => 'proto', default => 'https' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "owner:s" => { name => 'owner' }, - "repository:s" => { name => 'repository' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'api.github.com' }, + "port:s" => { name => 'port', default => '443'}, + "proto:s" => { name => 'proto', default => 'https' }, + "timeout:s" => { name => 'timeout' }, + "owner:s" => { name => 'owner' }, + "repository:s" => { name => 'repository' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{statefile_value} = centreon::plugins::statefile->new(%options); return $self; @@ -140,18 +137,10 @@ Port used by GitHub's API (Default: '443') Specify https if needed (Default: 'https') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--owner> Specify GitHub's owner diff --git a/apps/github/mode/issues.pm b/apps/github/mode/issues.pm index 53a674f11..92b36e784 100644 --- a/apps/github/mode/issues.pm +++ b/apps/github/mode/issues.pm @@ -33,22 +33,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'api.github.com' }, - "port:s" => { name => 'port', default => '443'}, - "proto:s" => { name => 'proto', default => 'https' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "owner:s" => { name => 'owner' }, - "repository:s" => { name => 'repository' }, - "label:s" => { name => 'label', default => '' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'api.github.com' }, + "port:s" => { name => 'port', default => '443'}, + "proto:s" => { name => 'proto', default => 'https' }, + "timeout:s" => { name => 'timeout' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "owner:s" => { name => 'owner' }, + "repository:s" => { name => 'repository' }, + "label:s" => { name => 'label', default => '' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -147,18 +144,10 @@ Port used by GitHub's API (Default: '443') Specify https if needed (Default: 'https') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Threshold warning. diff --git a/apps/github/mode/pullrequests.pm b/apps/github/mode/pullrequests.pm index 173bdcab0..ca4b3cd15 100644 --- a/apps/github/mode/pullrequests.pm +++ b/apps/github/mode/pullrequests.pm @@ -33,21 +33,18 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'api.github.com' }, - "port:s" => { name => 'port', default => '443' }, - "proto:s" => { name => 'proto', default => 'https' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "owner:s" => { name => 'owner' }, - "repository:s" => { name => 'repository' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'api.github.com' }, + "port:s" => { name => 'port', default => '443' }, + "proto:s" => { name => 'proto', default => 'https' }, + "timeout:s" => { name => 'timeout' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "owner:s" => { name => 'owner' }, + "repository:s" => { name => 'repository' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -132,18 +129,10 @@ Port used by GitHub's API (Default: '443') Specify https if needed (Default: 'https') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Threshold warning. diff --git a/apps/github/mode/stats.pm b/apps/github/mode/stats.pm index e0d5ab1c9..5e158e6c9 100644 --- a/apps/github/mode/stats.pm +++ b/apps/github/mode/stats.pm @@ -34,19 +34,16 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'api.github.com' }, - "port:s" => { name => 'port', default => '443'}, - "proto:s" => { name => 'proto', default => 'https' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "owner:s" => { name => 'owner' }, - "repository:s" => { name => 'repository' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'api.github.com' }, + "port:s" => { name => 'port', default => '443'}, + "proto:s" => { name => 'proto', default => 'https' }, + "timeout:s" => { name => 'timeout' }, + "owner:s" => { name => 'owner' }, + "repository:s" => { name => 'repository' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -131,18 +128,10 @@ Specify https if needed (Default: 'https') Set path to get GitHub's status information (Default: '/repo/:owner/:repository') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =cut diff --git a/apps/github/mode/status.pm b/apps/github/mode/status.pm index 0c038e4dd..96ab886f5 100644 --- a/apps/github/mode/status.pm +++ b/apps/github/mode/status.pm @@ -41,19 +41,16 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'status.github.com' }, - "port:s" => { name => 'port', default => '443'}, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => '/api/last-message.json' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'status.github.com' }, + "port:s" => { name => 'port', default => '443'}, + "proto:s" => { name => 'proto', default => 'https' }, + "urlpath:s" => { name => 'url_path', default => '/api/last-message.json' }, + "timeout:s" => { name => 'timeout' }, + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -151,18 +148,10 @@ Specify https if needed (Default: 'https') Set path to get GitHub's status information (Default: '/api/last-message.json') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--threshold-overload> Set to overload default threshold values (syntax: status,regexp) diff --git a/apps/jenkins/mode/jobstate.pm b/apps/jenkins/mode/jobstate.pm index c89de5509..3ba01e1b9 100644 --- a/apps/jenkins/mode/jobstate.pm +++ b/apps/jenkins/mode/jobstate.pm @@ -34,26 +34,23 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path' }, - "timeout:s" => { name => 'timeout' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "jobname:s" => { name => 'jobname' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "checkstyle" => { name => 'checkstyle' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path' }, + "timeout:s" => { name => 'timeout' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "jobname:s" => { name => 'jobname' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "checkstyle" => { name => 'checkstyle' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -180,18 +177,10 @@ Specify username for API authentification Specify password for API authentification -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for tendency score diff --git a/apps/kayako/api/mode/listdepartment.pm b/apps/kayako/api/mode/listdepartment.pm index 0d67778cf..a3d98c6c2 100644 --- a/apps/kayako/api/mode/listdepartment.pm +++ b/apps/kayako/api/mode/listdepartment.pm @@ -36,20 +36,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "kayako-api-key:s" => { name => 'kayako_api_key' }, - "kayako-secret-key:s" => { name => 'kayako_secret_key' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, + "timeout:s" => { name => 'timeout' }, + "kayako-api-key:s" => { name => 'kayako_api_key' }, + "kayako-secret-key:s" => { name => 'kayako_secret_key' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -116,10 +113,6 @@ Port used by Apache Specify https if needed -=item B<--proxyurl> - -Proxy URL if any - =item B<--urlpath> This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Default: '/api/index.php?') @@ -128,10 +121,6 @@ This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Def Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--kayako-api-key> This is your unique API key. diff --git a/apps/kayako/api/mode/listpriority.pm b/apps/kayako/api/mode/listpriority.pm index 1841c506e..aa4a6e146 100644 --- a/apps/kayako/api/mode/listpriority.pm +++ b/apps/kayako/api/mode/listpriority.pm @@ -36,20 +36,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "kayako-api-key:s" => { name => 'kayako_api_key' }, - "kayako-secret-key:s" => { name => 'kayako_secret_key' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, + "timeout:s" => { name => 'timeout' }, + "kayako-api-key:s" => { name => 'kayako_api_key' }, + "kayako-secret-key:s" => { name => 'kayako_secret_key' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -116,10 +113,6 @@ Port used by Apache Specify https if needed -=item B<--proxyurl> - -Proxy URL if any - =item B<--urlpath> This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Default: '/api/index.php?') @@ -128,10 +121,6 @@ This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Def Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--kayako-api-key> This is your unique API key. diff --git a/apps/kayako/api/mode/liststaff.pm b/apps/kayako/api/mode/liststaff.pm index ffcc00bf6..ba73c2302 100644 --- a/apps/kayako/api/mode/liststaff.pm +++ b/apps/kayako/api/mode/liststaff.pm @@ -34,20 +34,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "kayako-api-key:s" => { name => 'kayako_api_key' }, - "kayako-secret-key:s" => { name => 'kayako_secret_key' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, + "timeout:s" => { name => 'timeout' }, + "kayako-api-key:s" => { name => 'kayako_api_key' }, + "kayako-secret-key:s" => { name => 'kayako_secret_key' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -114,10 +111,6 @@ Port used by Apache Specify https if needed -=item B<--proxyurl> - -Proxy URL if any - =item B<--urlpath> This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Default: '/api/index.php?') @@ -126,10 +119,6 @@ This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Def Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--kayako-api-key> This is your unique API key. diff --git a/apps/kayako/api/mode/liststatus.pm b/apps/kayako/api/mode/liststatus.pm index 374940000..500afa70a 100644 --- a/apps/kayako/api/mode/liststatus.pm +++ b/apps/kayako/api/mode/liststatus.pm @@ -34,20 +34,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "kayako-api-key:s" => { name => 'kayako_api_key' }, - "kayako-secret-key:s" => { name => 'kayako_secret_key' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, + "timeout:s" => { name => 'timeout' }, + "kayako-api-key:s" => { name => 'kayako_api_key' }, + "kayako-secret-key:s" => { name => 'kayako_secret_key' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -114,10 +111,6 @@ Port used by Apache Specify https if needed -=item B<--proxyurl> - -Proxy URL if any - =item B<--urlpath> This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Default: '/api/index.php?') @@ -126,10 +119,6 @@ This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Def Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--kayako-api-key> This is your unique API key. diff --git a/apps/kayako/api/mode/ticketcount.pm b/apps/kayako/api/mode/ticketcount.pm index 82820122a..832e8075f 100644 --- a/apps/kayako/api/mode/ticketcount.pm +++ b/apps/kayako/api/mode/ticketcount.pm @@ -45,30 +45,27 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "kayako-api-key:s" => { name => 'kayako_api_key' }, - "kayako-secret-key:s" => { name => 'kayako_secret_key' }, - "reload-cache-time:s" => { name => 'reload_cache_time', default => 180 }, - "department-id:s" => { name => 'department_id' }, - "staff-id:s" => { name => 'staff_id' }, - "status-id:s" => { name => 'status_id' }, - "priority-id:s" => { name => 'priority_id' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "start-date:s" => { name => 'start_date' }, - "end-date:s" => { name => 'end_date' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => '/api/index.php?' }, + "timeout:s" => { name => 'timeout' }, + "kayako-api-key:s" => { name => 'kayako_api_key' }, + "kayako-secret-key:s" => { name => 'kayako_secret_key' }, + "reload-cache-time:s" => { name => 'reload_cache_time', default => 180 }, + "department-id:s" => { name => 'department_id' }, + "staff-id:s" => { name => 'staff_id' }, + "status-id:s" => { name => 'status_id' }, + "priority-id:s" => { name => 'priority_id' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "start-date:s" => { name => 'start_date' }, + "end-date:s" => { name => 'end_date' }, + }); $self->{statefile_cache} = centreon::plugins::statefile->new(%options); $self->{statefile_value} = centreon::plugins::statefile->new(%options); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -339,10 +336,6 @@ Port used by Apache Specify https if needed -=item B<--proxyurl> - -Proxy URL if any - =item B<--urlpath> This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Default: '/api/index.php?') @@ -351,10 +344,6 @@ This is the URL you should dispatch all GET, POST, PUT & DELETE requests to (Def Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--kayako-api-key> This is your unique API key. (required) diff --git a/apps/kingdee/eas/custom/api.pm b/apps/kingdee/eas/custom/api.pm index dcee5e5bc..b4fe2021e 100644 --- a/apps/kingdee/eas/custom/api.pm +++ b/apps/kingdee/eas/custom/api.pm @@ -39,23 +39,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "proto:s@" => { name => 'proto' }, - "port:s@" => { name => 'port' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "proto:s@" => { name => 'proto' }, + "port:s@" => { name => 'port' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -92,7 +89,6 @@ sub check_options { $self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'http'; $self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : 80; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -113,7 +109,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -169,18 +164,10 @@ Kingdee username. Kingdee password. -=item B<--proxyurl> - -Proxy URL if any. - =item B<--timeout> Set HTTP timeout in seconds (Default: '10'). -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/nginx/serverstatus/mode/connections.pm b/apps/nginx/serverstatus/mode/connections.pm index 0e8da72e5..beadcc04a 100644 --- a/apps/nginx/serverstatus/mode/connections.pm +++ b/apps/nginx/serverstatus/mode/connections.pm @@ -39,20 +39,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/nginx_status" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/nginx_status" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + }); foreach (@{$maps}) { $options{options}->add_options(arguments => { 'warning-' . $_->{counter} . ':s' => { name => 'warning_' . $_->{counter} }, @@ -60,7 +57,7 @@ sub new { }); } - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -127,10 +124,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol to use http or https, http is default @@ -163,10 +156,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning-*> Warning Threshold. Can be: 'active', 'waiting', 'writing', 'reading'. @@ -177,4 +166,4 @@ Critical Threshold. Can be: 'active', 'waiting', 'writing', 'reading'. =back -=cut \ No newline at end of file +=cut diff --git a/apps/nginx/serverstatus/mode/requests.pm b/apps/nginx/serverstatus/mode/requests.pm index c1e8cd840..4c9216097 100644 --- a/apps/nginx/serverstatus/mode/requests.pm +++ b/apps/nginx/serverstatus/mode/requests.pm @@ -39,20 +39,17 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/nginx_status" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/nginx_status" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + }); foreach (@{$maps}) { $options{options}->add_options(arguments => { 'warning-' . $_->{counter} . ':s' => { name => 'warning_' . $_->{counter} }, @@ -60,7 +57,7 @@ sub new { }); } $self->{statefile_value} = centreon::plugins::statefile->new(%options); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -175,10 +172,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -211,10 +204,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning-*> Warning Threshold. Can be: 'accepts', 'handled', 'requests'. diff --git a/apps/nginx/serverstatus/mode/responsetime.pm b/apps/nginx/serverstatus/mode/responsetime.pm index 48624073e..027d840dc 100644 --- a/apps/nginx/serverstatus/mode/responsetime.pm +++ b/apps/nginx/serverstatus/mode/responsetime.pm @@ -33,26 +33,23 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/nginx_status" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/nginx_status" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + "unknown-status:s" => { name => 'unknown_status', default => '' }, + "warning-status:s" => { name => 'warning_status' }, + "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -140,18 +137,10 @@ Specify this option if you access server-status page over hidden basic authentic (Use with --credentials) -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--unknown-status> Threshold warning for http response code diff --git a/apps/nsclient/restapi/mode/query.pm b/apps/nsclient/restapi/mode/query.pm index c945e9baa..1061bd88a 100644 --- a/apps/nsclient/restapi/mode/query.pm +++ b/apps/nsclient/restapi/mode/query.pm @@ -34,10 +34,8 @@ sub new { bless $self, $class; $self->{version} = '1.1'; - $options{options}->add_options(arguments => - { + $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, - "http-peer-addr:s" => { name => 'http_peer_addr' }, "port:s" => { name => 'port', default => 8443 }, "proto:s" => { name => 'proto', default => 'https' }, "credentials" => { name => 'credentials' }, @@ -45,19 +43,15 @@ sub new { "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, "legacy-password:s" => { name => 'legacy_password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "ssl:s" => { name => 'ssl' }, "command:s" => { name => 'command' }, "arg:s@" => { name => 'arg' }, "unknown-status:s" => { name => 'unknown_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, "warning-status:s" => { name => 'warning_status' }, "critical-status:s" => { name => 'critical_status', default => '' }, - }); + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -180,10 +174,6 @@ Query NSClient Rest API. IP Addr/FQDN of the host -=item B<--http-peer-addr> - -Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve) - =item B<--port> Port used (Default: 8443) @@ -216,22 +206,10 @@ Specify this option if you access webpage over hidden basic authentication or yo Specify password for old authentification system. -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--timeout> Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--command> Set command. diff --git a/apps/php/apc/web/mode/filecache.pm b/apps/php/apc/web/mode/filecache.pm index 576ae11d0..015881d0a 100644 --- a/apps/php/apc/web/mode/filecache.pm +++ b/apps/php/apc/web/mode/filecache.pm @@ -200,22 +200,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/apc.php" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/apc.php" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout', default => 30 }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -262,10 +259,6 @@ IP Addr/FQDN of the webserver host Port used by web server -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -298,10 +291,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout (Default: 30) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning-*> Threshold warning. diff --git a/apps/php/apc/web/mode/memory.pm b/apps/php/apc/web/mode/memory.pm index 492002161..dd262bf88 100644 --- a/apps/php/apc/web/mode/memory.pm +++ b/apps/php/apc/web/mode/memory.pm @@ -96,22 +96,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/apc.php" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/apc.php" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout', default => 30 }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -159,10 +156,6 @@ IP Addr/FQDN of the webserver host Port used by web server -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -195,10 +188,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout (Default: 30) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning-*> Threshold warning. diff --git a/apps/php/fpm/web/mode/usage.pm b/apps/php/fpm/web/mode/usage.pm index 4014e48e3..93bccd9fc 100644 --- a/apps/php/fpm/web/mode/usage.pm +++ b/apps/php/fpm/web/mode/usage.pm @@ -140,21 +140,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/fpm-status" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout', default => 5 }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/fpm-status" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout', default => 5 }, + }); + + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -202,10 +200,6 @@ IP Addr/FQDN of the webserver host Port used by web server -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -238,10 +232,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning-*> Threshold warning. diff --git a/apps/protocols/http/mode/expectedcontent.pm b/apps/protocols/http/mode/expectedcontent.pm index 3629454aa..f228155b4 100644 --- a/apps/protocols/http/mode/expectedcontent.pm +++ b/apps/protocols/http/mode/expectedcontent.pm @@ -70,24 +70,18 @@ sub new { $self->{version} = '1.2'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, - "http-peer-addr:s" => { name => 'http_peer_addr' }, "port:s" => { name => 'port', }, "method:s" => { name => 'method' }, "proto:s" => { name => 'proto' }, "urlpath:s" => { name => 'url_path' }, "credentials" => { name => 'credentials' }, "basic" => { name => 'basic' }, - "ntlm" => { name => 'ntlm' }, # Deprecated "ntlmv2" => { name => 'ntlmv2' }, "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, "expected-string:s" => { name => 'expected_string' }, "timeout:s" => { name => 'timeout' }, "no-follow" => { name => 'no_follow', }, - "ssl:s" => { name => 'ssl', }, - "ssl-opt:s@" => { name => 'ssl_opt' }, "cert-file:s" => { name => 'cert_file' }, "key-file:s" => { name => 'key_file' }, "cacert-file:s" => { name => 'cacert_file' }, @@ -102,7 +96,7 @@ sub new { "critical-status:s" => { name => 'critical_status' }, }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -165,22 +159,10 @@ Check Webpage content IP Addr/FQDN of the Webserver host -=item B<--http-peer-addr> - -Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve) - =item B<--port> Port used by Webserver -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--method> Specify http method used (Default: 'GET') @@ -225,10 +207,6 @@ Threshold for HTTP timeout (Default: 5) Do not follow http redirect -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--cert-file> Specify certificate to send to the webserver diff --git a/apps/protocols/http/mode/jsoncontent.pm b/apps/protocols/http/mode/jsoncontent.pm index 37ee8685b..4322b69ec 100644 --- a/apps/protocols/http/mode/jsoncontent.pm +++ b/apps/protocols/http/mode/jsoncontent.pm @@ -37,24 +37,18 @@ sub new { $self->{version} = '1.2'; $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, - "http-peer-addr:s" => { name => 'http_peer_addr' }, "vhost:s" => { name => 'vhost' }, "port:s" => { name => 'port', }, "proto:s" => { name => 'proto' }, "urlpath:s" => { name => 'url_path' }, "credentials" => { name => 'credentials' }, "basic" => { name => 'basic' }, - "ntlm" => { name => 'ntlm' }, # Deprecated "ntlmv2" => { name => 'ntlmv2' }, "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, "header:s@" => { name => 'header' }, "get-param:s@" => { name => 'get_param' }, "timeout:s" => { name => 'timeout', default => 10 }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "ssl:s" => { name => 'ssl', }, "cert-file:s" => { name => 'cert_file' }, "key-file:s" => { name => 'key_file' }, "cacert-file:s" => { name => 'cacert_file' }, @@ -94,7 +88,7 @@ sub new { $self->{values_string_warning} = []; $self->{values_string_critical} = []; $self->{values_string_unknown} = []; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -460,22 +454,10 @@ HTTP OPTIONS: IP Addr/FQDN of the Webserver host -=item B<--http-peer-addr> - -Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve) - =item B<--port> Port used by Webserver -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--proto> Specify https if needed @@ -512,10 +494,6 @@ Specify this option if you access webpage over ntlmv2 authentication (Use with - Threshold for HTTP timeout (Default: 10) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--cert-file> Specify certificate to send to the webserver diff --git a/apps/protocols/http/mode/response.pm b/apps/protocols/http/mode/response.pm index f1a26ae1b..8d7b8fb03 100644 --- a/apps/protocols/http/mode/response.pm +++ b/apps/protocols/http/mode/response.pm @@ -33,45 +33,38 @@ sub new { bless $self, $class; $self->{version} = '1.1'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "http-peer-addr:s" => { name => 'http_peer_addr' }, - "port:s" => { name => 'port', }, - "method:s" => { name => 'method' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "ntlm" => { name => 'ntlm' }, # Deprecated - "ntlmv2" => { name => 'ntlmv2' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "timeout:s" => { name => 'timeout' }, - "no-follow" => { name => 'no_follow', }, - "ssl:s" => { name => 'ssl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "cert-pwd:s" => { name => 'cert_pwd' }, - "cert-pkcs12" => { name => 'cert_pkcs12' }, - "header:s@" => { name => 'header' }, - "get-param:s@" => { name => 'get_param' }, - "post-param:s@" => { name => 'post_param' }, - "cookies-file:s" => { name => 'cookies_file' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "warning-size:s" => { name => 'warning_size' }, - "critical-size:s" => { name => 'critical_size' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "method:s" => { name => 'method' }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "ntlmv2" => { name => 'ntlmv2' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "no-follow" => { name => 'no_follow', }, + "cert-file:s" => { name => 'cert_file' }, + "key-file:s" => { name => 'key_file' }, + "cacert-file:s" => { name => 'cacert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + "header:s@" => { name => 'header' }, + "get-param:s@" => { name => 'get_param' }, + "post-param:s@" => { name => 'post_param' }, + "cookies-file:s" => { name => 'cookies_file' }, + "unknown-status:s" => { name => 'unknown_status', default => '' }, + "warning-status:s" => { name => 'warning_status' }, + "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "warning-size:s" => { name => 'warning_size' }, + "critical-size:s" => { name => 'critical_size' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -153,10 +146,6 @@ Check Webpage response and size. IP Addr/FQDN of the webserver host -=item B<--http-peer-addr> - -Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve) - =item B<--port> Port used by Webserver @@ -197,14 +186,6 @@ Specify this option if you access webpage over hidden basic authentication or yo Specify this option if you access webpage over ntlmv2 authentication (Use with --credentials and --port options) -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--timeout> Threshold for HTTP timeout (Default: 5) @@ -213,10 +194,6 @@ Threshold for HTTP timeout (Default: 5) Do not follow http redirect -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--cert-file> Specify certificate to send to the webserver diff --git a/apps/protocols/http/mode/soapcontent.pm b/apps/protocols/http/mode/soapcontent.pm index 43dc8cb8e..4ed0200eb 100644 --- a/apps/protocols/http/mode/soapcontent.pm +++ b/apps/protocols/http/mode/soapcontent.pm @@ -34,49 +34,42 @@ sub new { bless $self, $class; $self->{version} = '1.2'; - $options{options}->add_options(arguments => - { - "service-soap:s" => { name => 'service_soap' }, - "data:s" => { name => 'data' }, - "lookup:s@" => { name => 'lookup' }, - "hostname:s" => { name => 'hostname' }, - "http-peer-addr:s" => { name => 'http_peer_addr' }, - "vhost:s" => { name => 'vhost' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "ntlm" => { name => 'ntlm' }, # Deprecated - "ntlmv2" => { name => 'ntlmv2' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "header:s@" => { name => 'header' }, - "timeout:s" => { name => 'timeout', default => 10 }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "ssl:s" => { name => 'ssl', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "cert-pwd:s" => { name => 'cert_pwd' }, - "cert-pkcs12" => { name => 'cert_pkcs12' }, - "unknown-status:s" => { name => 'unknown_status' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status' }, - "warning-numeric:s" => { name => 'warning_numeric' }, - "critical-numeric:s" => { name => 'critical_numeric' }, - "warning-string:s" => { name => 'warning_string' }, - "critical-string:s" => { name => 'critical_string' }, - "warning-time:s" => { name => 'warning_time' }, - "critical-time:s" => { name => 'critical_time' }, - "threshold-value:s" => { name => 'threshold_value', default => 'count' }, - "format-ok:s" => { name => 'format_ok', default => '%{count} element(s) found' }, - "format-warning:s" => { name => 'format_warning', default => '%{count} element(s) found' }, - "format-critical:s" => { name => 'format_critical', default => '%{count} element(s) found' }, - "values-separator:s" => { name => 'values_separator', default => ', ' }, - }); + $options{options}->add_options(arguments => { + "service-soap:s" => { name => 'service_soap' }, + "data:s" => { name => 'data' }, + "lookup:s@" => { name => 'lookup' }, + "hostname:s" => { name => 'hostname' }, + "vhost:s" => { name => 'vhost' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "ntlmv2" => { name => 'ntlmv2' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "header:s@" => { name => 'header' }, + "timeout:s" => { name => 'timeout', default => 10 }, + "cert-file:s" => { name => 'cert_file' }, + "key-file:s" => { name => 'key_file' }, + "cacert-file:s" => { name => 'cacert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + "unknown-status:s" => { name => 'unknown_status' }, + "warning-status:s" => { name => 'warning_status' }, + "critical-status:s" => { name => 'critical_status' }, + "warning-numeric:s" => { name => 'warning_numeric' }, + "critical-numeric:s" => { name => 'critical_numeric' }, + "warning-string:s" => { name => 'warning_string' }, + "critical-string:s" => { name => 'critical_string' }, + "warning-time:s" => { name => 'warning_time' }, + "critical-time:s" => { name => 'critical_time' }, + "threshold-value:s" => { name => 'threshold_value', default => 'count' }, + "format-ok:s" => { name => 'format_ok', default => '%{count} element(s) found' }, + "format-warning:s" => { name => 'format_warning', default => '%{count} element(s) found' }, + "format-critical:s" => { name => 'format_critical', default => '%{count} element(s) found' }, + "values-separator:s" => { name => 'values_separator', default => ', ' }, + }); $self->{count} = 0; $self->{count_ok} = 0; $self->{count_warning} = 0; @@ -87,7 +80,7 @@ sub new { $self->{values_string_ok} = []; $self->{values_string_warning} = []; $self->{values_string_critical} = []; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -165,8 +158,7 @@ sub check_encoding { my ($self, %options) = @_; my $charset; - my $headers = $self->{http}->get_header(); - my $content_type = $headers->header('Content-Type'); + my ($content_type) = $self->{http}->get_header(name => 'Content-Type'); if (defined($content_type) && $content_type =~ /charset\s*=\s*(\S+)/i) { $charset = $1; } @@ -394,22 +386,10 @@ HTTP OPTIONS: IP Addr/FQDN of the Webserver host -=item B<--http-peer-addr> - -Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve) - =item B<--port> Port used by Webserver -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--proto> Specify https if needed @@ -446,10 +426,6 @@ Specify this option if you access webpage over ntlmv2 authentication (Use with - Threshold for HTTP timeout (Default: 10) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--cert-file> Specify certificate to send to the webserver diff --git a/apps/proxmox/ve/restapi/custom/api.pm b/apps/proxmox/ve/restapi/custom/api.pm index 25878ab69..055452e4c 100644 --- a/apps/proxmox/ve/restapi/custom/api.pm +++ b/apps/proxmox/ve/restapi/custom/api.pm @@ -44,27 +44,24 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port'}, - "proto:s" => { name => 'proto' }, - "api-username:s" => { name => 'api_username' }, - "api-password:s" => { name => 'api_password' }, - "realm:s" => { name => 'realm' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "reload-cache-time:s" => { name => 'reload_cache_time', default => 7200 }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port'}, + "proto:s" => { name => 'proto' }, + "api-username:s" => { name => 'api_username' }, + "api-password:s" => { name => 'api_password' }, + "realm:s" => { name => 'realm' }, + "timeout:s" => { name => 'timeout' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "reload-cache-time:s" => { name => 'reload_cache_time', default => 7200 }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{cache} = centreon::plugins::statefile->new(%options); return $self; @@ -99,7 +96,6 @@ sub check_options { $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8006; $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->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; $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; @@ -143,7 +139,6 @@ sub build_options_for_httplib { $self->{option_results}->{proto} = $self->{proto}; $self->{option_results}->{ssl_opt} = $self->{ssl_opt}; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; $self->{option_results}->{unknown_status} = ''; @@ -540,22 +535,10 @@ Set Proxmox VE Password Set Proxmox VE Realm (pam, pve or custom) (Default: 'pam'). -=item B<--proxyurl> - -Proxy URL if any. - -=item B<--proxypac> - -Proxy pac file (can be an url or local file). - =item B<--timeout> Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =cut diff --git a/apps/pvx/restapi/custom/api.pm b/apps/pvx/restapi/custom/api.pm index 8663d4b80..b2d354164 100644 --- a/apps/pvx/restapi/custom/api.pm +++ b/apps/pvx/restapi/custom/api.pm @@ -42,28 +42,25 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "api-key:s" => { name => 'api_key' }, - "hostname:s" => { name => 'hostname' }, - "url-path:s" => { name => 'url_path' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "timeframe:s" => { name => 'timeframe' }, - }); + $options{options}->add_options(arguments => { + "api-key:s" => { name => 'api_key' }, + "hostname:s" => { name => 'hostname' }, + "url-path:s" => { name => 'url_path' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "timeframe:s" => { name => 'timeframe' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'RESTAPI OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -100,8 +97,6 @@ sub check_options { $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/api'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; $self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : undef; $self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef; $self->{credentials} = (defined($self->{option_results}->{credentials})) ? 1 : undef; @@ -127,7 +122,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = $self->{credentials}; $self->{option_results}->{basic} = $self->{basic}; $self->{option_results}->{username} = $self->{username}; @@ -263,18 +257,10 @@ Specify this option if you access the API over hidden basic authentication or yo (Use with --credentials) -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/redis/restapi/custom/api.pm b/apps/redis/restapi/custom/api.pm index 2d5937cd0..ec48605bf 100644 --- a/apps/redis/restapi/custom/api.pm +++ b/apps/redis/restapi/custom/api.pm @@ -40,25 +40,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "interval:s@" => { name => 'interval' }, - "hostname:s@" => { name => 'hostname' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl:s@" => { name => 'ssl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "interval:s@" => { name => 'interval' }, + "hostname:s@" => { name => 'hostname' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -95,8 +91,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; - $self->{ssl} = (defined($self->{option_results}->{ssl})) ? shift(@{$self->{option_results}->{ssl}}) : 'tlsv1'; $self->{interval} = (defined($self->{option_results}->{interval})) ? shift(@{$self->{option_results}->{interval}}) : '15min'; if (!defined($self->{hostname})) { @@ -119,12 +113,10 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; $self->{option_results}->{password} = $self->{password}; - $self->{option_results}->{ssl} = $self->{ssl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -226,18 +218,10 @@ Cluster username. Cluster password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/rudder/restapi/custom/api.pm b/apps/rudder/restapi/custom/api.pm index 6f43e58b2..2be87b374 100644 --- a/apps/rudder/restapi/custom/api.pm +++ b/apps/rudder/restapi/custom/api.pm @@ -47,16 +47,14 @@ sub new { "port:s" => { name => 'port' }, "proto:s" => { name => 'proto' }, "api-token:s" => { name => 'api_token' }, - "proxyurl:s" => { name => 'proxyurl' }, "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -165,7 +163,6 @@ sub request_api { $self->{url_path} . $options{url_path} . "'", debug => 1); my $content = $self->{http}->request(url_path => $self->{url_path} . $options{url_path}); - my $response = $self->{http}->get_response(); my $decoded; eval { @@ -218,18 +215,10 @@ Specify https if needed (Default: 'https') API URL path (Default: '/rudder/api/latest') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL option (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/slack/restapi/custom/api.pm b/apps/slack/restapi/custom/api.pm index da5526c36..e01afe177 100644 --- a/apps/slack/restapi/custom/api.pm +++ b/apps/slack/restapi/custom/api.pm @@ -40,23 +40,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "api-path:s" => { name => 'api_path' }, - "api-token:s" => { name => 'api_token' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "timeout:s" => { name => 'timeout' }, + "api-path:s" => { name => 'api_path' }, + "api-token:s" => { name => 'api_token' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -91,8 +88,6 @@ sub check_options { $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : undef; $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->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/api'; $self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : undef; @@ -115,8 +110,6 @@ sub build_options_for_httplib { $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; - $self->{option_results}->{ssl_opt} = $self->{ssl_opt}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -140,7 +133,6 @@ sub request_api { my $content = $self->{http}->request(method => $options{method}, url_path => $self->{api_path} . $options{url_path}, query_form_post => $options{query_form_post}, critical_status => '', warning_status => '', unknown_status => ''); - my $response = $self->{http}->get_response(); my $decoded; eval { $decoded = decode_json($content); @@ -218,19 +210,10 @@ Slack API port Specify https if needed (Default: 'https') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (Examples: --ssl-opt="SSL_version => TLSv1" ---ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/tomcat/web/mode/applications.pm b/apps/tomcat/web/mode/applications.pm index 1d909cca9..348d03dd9 100644 --- a/apps/tomcat/web/mode/applications.pm +++ b/apps/tomcat/web/mode/applications.pm @@ -31,27 +31,24 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/text/list' }, - "name:s" => { name => 'name' }, - "regexp" => { name => 'use_regexp' }, - "regexp-isensitive" => { name => 'use_regexpi' }, - "filter-path:s" => { name => 'filter_path', }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/text/list' }, + "name:s" => { name => 'name' }, + "regexp" => { name => 'use_regexp' }, + "regexp-isensitive" => { name => 'use_regexpi' }, + "filter-path:s" => { name => 'filter_path', }, + }); $self->{result} = {}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -155,10 +152,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -187,10 +180,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--urlpath> Path to the Tomcat Manager List (Default: Tomcat 7 '/manager/text/list') diff --git a/apps/tomcat/web/mode/listapplication.pm b/apps/tomcat/web/mode/listapplication.pm index 57ad1d817..3b4396cbe 100644 --- a/apps/tomcat/web/mode/listapplication.pm +++ b/apps/tomcat/web/mode/listapplication.pm @@ -31,26 +31,23 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/text/list' }, - "filter-name:s" => { name => 'filter_name', }, - "filter-state:s" => { name => 'filter_state', }, - "filter-path:s" => { name => 'filter_path', }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/text/list' }, + "filter-name:s" => { name => 'filter_name', }, + "filter-state:s" => { name => 'filter_state', }, + "filter-path:s" => { name => 'filter_path', }, + }); $self->{result} = {}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -138,10 +135,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -170,10 +163,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--url-path> Path to the Tomcat Manager List (Default: Tomcat 7 '/manager/text/list') diff --git a/apps/tomcat/web/mode/memory.pm b/apps/tomcat/web/mode/memory.pm index 61f316f9f..297651586 100644 --- a/apps/tomcat/web/mode/memory.pm +++ b/apps/tomcat/web/mode/memory.pm @@ -32,25 +32,22 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); $self->{result} = {}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -190,10 +187,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -222,10 +215,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--urlpath> Path to the Tomcat Manager XML (Default: '/manager/status?XML=true') diff --git a/apps/tomcat/web/mode/requestinfo.pm b/apps/tomcat/web/mode/requestinfo.pm index d36150e64..25e33ed20 100644 --- a/apps/tomcat/web/mode/requestinfo.pm +++ b/apps/tomcat/web/mode/requestinfo.pm @@ -35,36 +35,33 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, - "name:s" => { name => 'name' }, - "regexp" => { name => 'use_regexp' }, - "regexp-isensitive" => { name => 'use_regexpi' }, - "warning-maxtime:s" => { name => 'warning_maxtime' }, - "critical-maxtime:s" => { name => 'critical_maxtime' }, - "warning-processingtime:s" => { name => 'warning_processingtime' }, - "critical-processingtime:s" => { name => 'critical_processingtime' }, - "warning-requestcount:s" => { name => 'warning_requestcount' }, - "critical-requestcount:s" => { name => 'critical_requestcount' }, - "warning-errorcount:s" => { name => 'warning_errorcount' }, - "critical-errorcount:s" => { name => 'critical_errorcount' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, + "name:s" => { name => 'name' }, + "regexp" => { name => 'use_regexp' }, + "regexp-isensitive" => { name => 'use_regexpi' }, + "warning-maxtime:s" => { name => 'warning_maxtime' }, + "critical-maxtime:s" => { name => 'critical_maxtime' }, + "warning-processingtime:s" => { name => 'warning_processingtime' }, + "critical-processingtime:s" => { name => 'critical_processingtime' }, + "warning-requestcount:s" => { name => 'warning_requestcount' }, + "critical-requestcount:s" => { name => 'critical_requestcount' }, + "warning-errorcount:s" => { name => 'warning_errorcount' }, + "critical-errorcount:s" => { name => 'critical_errorcount' }, + }); $self->{result} = {}; $self->{hostname} = undef; $self->{statefile_value} = centreon::plugins::statefile->new(%options); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -332,10 +329,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -364,10 +357,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--urlpath> Path to the Tomcat Manager XML (Default: '/manager/status?XML=true') diff --git a/apps/tomcat/web/mode/sessions.pm b/apps/tomcat/web/mode/sessions.pm index f6cc0c94a..9cbaea6ef 100644 --- a/apps/tomcat/web/mode/sessions.pm +++ b/apps/tomcat/web/mode/sessions.pm @@ -31,30 +31,27 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/text/list' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "name:s" => { name => 'name' }, - "regexp" => { name => 'use_regexp' }, - "regexp-isensitive" => { name => 'use_regexpi' }, - "filter-state:s" => { name => 'filter_state' }, - "filter-path:s" => { name => 'filter_path', }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/text/list' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "name:s" => { name => 'name' }, + "regexp" => { name => 'use_regexp' }, + "regexp-isensitive" => { name => 'use_regexpi' }, + "filter-state:s" => { name => 'filter_state' }, + "filter-path:s" => { name => 'filter_path', }, + }); $self->{result} = {}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -158,10 +155,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -190,10 +183,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--urlpath> Path to the Tomcat Manager List (Default: Tomcat 7 '/manager/text/list') diff --git a/apps/tomcat/web/mode/threads.pm b/apps/tomcat/web/mode/threads.pm index aa5382f1c..f048b6899 100644 --- a/apps/tomcat/web/mode/threads.pm +++ b/apps/tomcat/web/mode/threads.pm @@ -33,29 +33,26 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "name:s" => { name => 'name' }, - "regexp" => { name => 'use_regexp' }, - "regexp-isensitive" => { name => 'use_regexpi' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "name:s" => { name => 'name' }, + "regexp" => { name => 'use_regexp' }, + "regexp-isensitive" => { name => 'use_regexpi' }, + }); $self->{result} = {}; $self->{hostname} = undef; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -226,10 +223,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -258,10 +251,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--urlpath> Path to the Tomcat Manager XML (Default: '/manager/status?XML=true') diff --git a/apps/tomcat/web/mode/traffic.pm b/apps/tomcat/web/mode/traffic.pm index 5d533209a..8841fef4d 100644 --- a/apps/tomcat/web/mode/traffic.pm +++ b/apps/tomcat/web/mode/traffic.pm @@ -138,26 +138,23 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8080' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, - "filter-name:s" => { name => 'filter_name' }, - "speed-in:s" => { name => 'speed_in' }, - "speed-out:s" => { name => 'speed_out' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => '8080' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "urlpath:s" => { name => 'url_path', default => '/manager/status?XML=true' }, + "filter-name:s" => { name => 'filter_name' }, + "speed-in:s" => { name => 'speed_in' }, + "speed-out:s" => { name => 'speed_out' }, + "units-traffic:s" => { name => 'units_traffic', default => '%' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -285,10 +282,6 @@ IP Address or FQDN of the Tomcat Application Server Port used by Tomcat -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Protocol used http or https @@ -317,10 +310,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--urlpath> Path to the Tomcat Manager XML (Default: '/manager/status?XML=true') diff --git a/apps/video/zixi/restapi/custom/api.pm b/apps/video/zixi/restapi/custom/api.pm index ced835c5c..416ee7ed6 100644 --- a/apps/video/zixi/restapi/custom/api.pm +++ b/apps/video/zixi/restapi/custom/api.pm @@ -40,23 +40,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -100,7 +97,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -121,7 +117,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -194,18 +189,10 @@ Zixi username. Zixi password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/apps/vtom/restapi/custom/api.pm b/apps/vtom/restapi/custom/api.pm index 06a3d3d08..1b29c9c5f 100644 --- a/apps/vtom/restapi/custom/api.pm +++ b/apps/vtom/restapi/custom/api.pm @@ -40,23 +40,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -100,7 +97,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -121,7 +117,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -236,18 +231,10 @@ Storeonce username. Storeonce password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/centreon/plugins/backend/http/curl.pm b/centreon/plugins/backend/http/curl.pm new file mode 100644 index 000000000..78fdd24fb --- /dev/null +++ b/centreon/plugins/backend/http/curl.pm @@ -0,0 +1,428 @@ +# +# Copyright 2019 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package centreon::plugins::backend::http::curl; + +use strict; +use warnings; +use URI; +use centreon::plugins::misc; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + + if (!defined($options{noptions}) || $options{noptions} != 1) { + $options{options}->add_options(arguments => { + "curl-opt:s@" => { name => 'curl_opt' }, + }); + $options{options}->add_help(package => __PACKAGE__, sections => 'BACKEND CURL OPTIONS', once => 1); + } + + $self->{output} = $options{output}; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Net::Curl::Easy', + error_msg => "Cannot load module 'Net::Curl::Easy'."); + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'centreon::plugins::backend::http::curlconstants', + error_msg => "Cannot load module 'centreon::plugins::backend::http::curlconstants'."); + $self->{constant_cb} = \¢reon::plugins::backend::http::curlconstants::get_constant_value; + + foreach (('unknown_status', 'warning_status', 'critical_status')) { + if (defined($options{request}->{$_})) { + $options{request}->{$_} =~ s/%\{http_code\}/\$self->{response_code}/g; + } + } + + if (!defined($options{request}->{curl_opt})) { + $options{request}->{curl_opt} = []; + } +} + +my $http_code_explained = { + 100 => 'Continue', + 101 => 'Switching Protocols', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 306 => '(Unused)', + 307 => 'Temporary Redirect', + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported', +}; + +sub cb_debug { + my ($easy, $type, $data, $uservar) = @_; + + my $msg = ''; + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_TEXT')) { + $msg = sprintf("== Info: %s", $data); + } + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_HEADER_OUT')) { + $msg = sprintf("=> Send header: %s", $data); + } + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_DATA_OUT')) { + $msg = sprintf("=> Send data: %s", $data); + } + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_SSL_DATA_OUT')) { + $msg = sprintf("=> Send SSL data: %s", $data); + } + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_HEADER_IN')) { + $msg = sprintf("=> Recv header: %s", $data); + } + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_DATA_IN')) { + $msg = sprintf("=> Recv data: %s", $data); + } + if ($type == $uservar->{constant_cb}->(name => 'CURLINFO_SSL_DATA_IN')) { + $msg = sprintf("=> Recv SSL data: %s", $data); + } + + $uservar->{output}->output_add(long_msg => $msg, debug => 1); + return 0; +} + +sub curl_setopt { + my ($self, %options) = @_; + + eval { + $self->{curl_easy}->setopt($options{option}, $options{parameter}); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "curl setopt error: '" . $@ . "'."); + $self->{output}->option_exit(); + } +} + +sub set_method { + my ($self, %options) = @_; + + if ($options{request}->{method} eq 'GET') { + return ; + } + + 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 ''); + } elsif (defined($options{request}->{post_params})) { + my $uri_post = URI->new(); + $uri_post->query_form($options{request}->{post_params}); + push @{$options{headers}}, 'Content-Type: application/x-www-form-urlencoded'; + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_POSTFIELDS'), parameter => $uri_post->query); + } + + if ($options{request}->{method} eq 'POST') { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_POST'), parameter => 1); + } + if ($options{request}->{method} eq 'PUT') { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_CUSTOMREQUEST'), parameter => $options{request}->{method}); + } + if ($options{request}->{method} eq 'DELETE') { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_CUSTOMREQUEST'), parameter => $options{request}->{method}); + } +} + +sub set_auth { + my ($self, %options) = @_; + + if (defined($options{request}->{credentials})) { + if (defined($options{request}->{basic})) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_HTTPAUTH'), parameter => $self->{constant_cb}->(name => 'CURLAUTH_BASIC')); + } elsif (defined($options{request}->{ntlmv2})) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_HTTPAUTH'), parameter => $self->{constant_cb}->(name => 'CURLAUTH_NTLM')); + } else { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_HTTPAUTH'), parameter => $self->{constant_cb}->(name => 'CURLAUTH_ANY')); + } + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_USERPWD'), parameter => $options{request}->{username} . ':' . $options{request}->{password}); + } + + if (defined($options{request}->{cert_file}) && $options{request}->{cert_file} ne '') { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_SSLCERT'), parameter => $options{request}->{cert_file}); + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_SSLKEY'), parameter => $options{request}->{key_file}); + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_KEYPASSWD'), parameter => $options{request}->{cert_pwd}); + } + + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_SSLCERTTYPE'), parameter => "PEM"); + if (defined($options{request}->{cert_pkcs12})) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_SSLCERTTYPE'), parameter => "P12"); + } +} + +sub set_proxy { + my ($self, %options) = @_; + + if (defined($options{request}->{proxyurl}) && $options{request}->{proxyurl} ne '') { + if ($options{request}->{proxyurl} =~ /^(?:http|https):\/\/(.*?):(.*?)@/) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_PROXYUSERNAME'), parameter => $1); + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_PROXYPASSWORD'), parameter => $2); + $options{request}->{proxyurl} =~ s/\/\/$1:$2@//; + } + + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_PROXY'), parameter => $options{request}->{proxyurl}); + } + + if (defined($options{request}->{proxypac}) && $options{request}->{proxypac} ne '') { + $self->{output}->add_option_msg(short_msg => 'Unsupported proxypac option'); + $self->{output}->option_exit(); + } +} + +sub set_extra_curl_opt { + my ($self, %options) = @_; + + my $fields = { key => '', value => '' }; + foreach (@{$options{request}->{curl_opt}}) { + ($fields->{key}, $fields->{value}) = split /=>/; + foreach my $label ('key', 'value') { + $fields->{$label} = centreon::plugins::misc::trim($fields->{$label}); + if ($fields->{$label} =~ /^CURLOPT|CURL/) { + $fields->{$label} = $self->{constant_cb}->(name => $fields->{$label}); + } + } + + $self->curl_setopt(option => $fields->{key}, parameter => $fields->{value}); + } +} + +sub parse_headers { + my ($self, %options) = @_; + + $self->{response_headers_parse} = {}; + my ($header, $value); + foreach (split /\n/, $self->{response_headers}) { + s/\r//g; + if (/^(\S(?:.*?))\s*:\s*(.*)/) { + if (defined($value)) { + $self->{response_headers_parse}->{$header} = [] + if (!defined($self->{response_headers_parse}->{$header})); + push @{$self->{response_headers_parse}->{$header}}, $value; + } + $header = $1; + $value = $2; + } elsif (/^\s+(.*)/) { + $value .= ', ' . $1; + } + } + + if (defined($value)) { + $self->{response_headers_parse}->{$header} = [] + if (!defined($self->{response_headers_parse}->{$header})); + push @{$self->{response_headers_parse}->{$header}}, $value; + } +} + +sub request { + my ($self, %options) = @_; + + $self->{curl_easy} = Net::Curl::Easy->new(); + + if ($self->{output}->is_debug()) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_DEBUGFUNCTION'), parameter => \&cb_debug); + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_DEBUGDATA'), parameter => $self); + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_VERBOSE'), parameter => 1); + } + + if (defined($options{request}->{timeout})) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_TIMEOUT'), parameter => $options{request}->{timeout}); + } + if (defined($options{request}->{cookies_file})) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_COOKIEFILE'), parameter => $options{request}->{cookies_file}); + } + + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_FOLLOWLOCATION'), parameter => 1); + if (defined($options{request}->{no_follow})) { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_FOLLOWLOCATION'), parameter => 0); + } + + my $url; + if (defined($options{request}->{full_url})) { + $url = $options{request}->{full_url}; + } elsif (defined($options{request}->{port}) && $options{request}->{port} =~ /^[0-9]+$/) { + $url = $options{request}->{proto}. "://" . $options{request}->{hostname} . ':' . $options{request}->{port} . $options{request}->{url_path}; + } else { + $url = $options{request}->{proto}. "://" . $options{request}->{hostname} . $options{request}->{url_path}; + } + + if (defined($options{request}->{http_peer_addr}) && $options{request}->{http_peer_addr} ne '') { + $url =~ /^(?:http|https):\/\/(.*?)(\/|\:|$)/; + $self->{curl_easy}->pushopt($self->{constant_cb}->(name => 'CURLOPT_RESOLVE'), + [$1 . ':' . $options{request}->{port_force} . ':' . $options{request}->{http_peer_addr}]); + } + + my $uri = URI->new($url); + if (defined($options{request}->{get_params})) { + $uri->query_form($options{request}->{get_params}); + } + + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_URL'), parameter => $uri); + + my $headers = []; + my $content_type_forced = 0; + foreach my $key (keys %{$options{request}->{headers}}) { + push @$headers, $key . ':' . $options{request}->{headers}->{$key}; + if ($key =~ /content-type/i) { + $content_type_forced = 1; + } + } + + $self->set_method(%options, content_type_forced => $content_type_forced, headers => $headers); + + if (scalar(@$headers) > 0) { + $self->{curl_easy}->pushopt($self->{constant_cb}->(name => 'CURLOPT_HTTPHEADER'), $headers); + } + + if (defined($options{request}->{cacert_file}) && $options{request}->{cacert_file} ne '') { + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_CAINFO'), parameter => $options{request}->{cacert_file}); + } + + $self->set_auth(%options); + $self->set_proxy(%options); + $self->set_extra_curl_opt(%options); + + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_FILE'), parameter => \$self->{response_body}); + $self->curl_setopt(option => $self->{constant_cb}->(name => 'CURLOPT_HEADERDATA'), parameter => \$self->{response_headers}); + + eval { + $self->{curl_easy}->perform(); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => 'curl perform error : ' . $@); + $self->{output}->option_exit(); + } + + $self->{response_code} = $self->{curl_easy}->getinfo($self->{constant_cb}->(name => 'CURLINFO_RESPONSE_CODE')); + $self->parse_headers(); + + # Check response + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($options{request}->{critical_status}) && $options{request}->{critical_status} ne '' && + eval "$options{request}->{critical_status}") { + $status = 'critical'; + } elsif (defined($options{request}->{warning_status}) && $options{request}->{warning_status} ne '' && + eval "$options{request}->{warning_status}") { + $status = 'warning'; + } elsif (defined($options{request}->{unknown_status}) && $options{request}->{unknown_status} ne '' && + eval "$options{request}->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->add_option_msg(short_msg => 'filter status issue: ' . $message); + $self->{output}->option_exit(); + } + + if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { + my $short_msg = $self->{response_code} . ' ' . + (defined($http_code_explained->{$self->{response_code}}) ? $http_code_explained->{$self->{response_code}} : 'unknown'); + + $self->{output}->output_add(severity => $status, + short_msg => $short_msg); + $self->{output}->display(); + $self->{output}->exit(); + } + + return $self->{response_body}; +} + +sub get_header { + my ($self, %options) = @_; + + return undef + if (!defined($self->{response_headers_parse}->{$options{name}})); + return wantarray ? @{$self->{response_headers_parse}->{$options{name}}} : $self->{response_headers_parse}->{$options{name}}->[0]; +} + +sub get_code { + my ($self, %options) = @_; + + return $self->{response_code}; +} + +1; + + +__END__ + +=head1 NAME + +HTTP Curl backend layer. + +=head1 SYNOPSIS + +HTTP Curl backend layer. + +=head1 BACKEND CURL OPTIONS + +=over 8 + +=item B<--curl-opt> + +Set CURL Options (--curl-opt="CURLOPT_SSL_VERIFYPEER => 0" --curl-opt="CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_1" ). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon/plugins/backend/http/curlconstants.pm b/centreon/plugins/backend/http/curlconstants.pm new file mode 100644 index 000000000..6c30d01f2 --- /dev/null +++ b/centreon/plugins/backend/http/curlconstants.pm @@ -0,0 +1,33 @@ +# +# Copyright 2019 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package centreon::plugins::backend::http::curlconstants; + +use strict; +use warnings; +use Net::Curl::Easy qw(:constants); + +sub get_constant_value { + my (%options) = @_; + + return eval $options{name}; +} + +1; diff --git a/centreon/plugins/backend/http/lwp.pm b/centreon/plugins/backend/http/lwp.pm new file mode 100644 index 000000000..553f1261f --- /dev/null +++ b/centreon/plugins/backend/http/lwp.pm @@ -0,0 +1,283 @@ +# +# Copyright 2019 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package centreon::plugins::backend::http::lwp; + +use strict; +use warnings; +use centreon::plugins::backend::http::useragent; +use URI; +use IO::Socket::SSL; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + + if (!defined($options{noptions}) || $options{noptions} != 1) { + $options{options}->add_options(arguments => { + "ssl:s" => { name => 'ssl' }, + "ssl-opt:s@" => { name => 'ssl_opt' }, + }); + $options{options}->add_help(package => __PACKAGE__, sections => 'BACKEND LWP OPTIONS', once => 1); + } + + $self->{output} = $options{output}; + $self->{ua} = undef; + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + + foreach (('unknown_status', 'warning_status', 'critical_status')) { + if (defined($options{request}->{$_})) { + $options{request}->{$_} =~ s/%\{http_code\}/\$self->{response}->code/g; + } + } + + $self->{ssl_context} = ''; + if (!defined($options{request}->{ssl_opt})) { + $options{request}->{ssl_opt} = []; + } + if (defined($options{request}->{ssl}) && $options{request}->{ssl} ne '') { + push @{$options{request}->{ssl_opt}}, 'SSL_version => ' . $options{request}->{ssl}; + } + if (defined($options{request}->{cert_file}) && !defined($options{request}->{cert_pkcs12})) { + push @{$options{request}->{ssl_opt}}, 'SSL_use_cert => 1'; + push @{$options{request}->{ssl_opt}}, 'SSL_cert_file => "' . $options{request}->{cert_file} . '"'; + push @{$options{request}->{ssl_opt}}, 'SSL_key_file => "' . $options{request}->{key_file} . '"' + if (defined($options{request}->{key_file})); + push @{$options{request}->{ssl_opt}}, 'SSL_ca_file => "' . $options{request}->{cacert_file} . '"' + if (defined($options{request}->{cacert_file})); + } + my $append = ''; + foreach (@{$options{request}->{ssl_opt}}) { + if ($_ ne '') { + $self->{ssl_context} .= $append . $_; + $append = ', '; + } + } +} + +sub set_proxy { + my ($self, %options) = @_; + + if (defined($options{request}->{proxypac}) && $options{request}->{proxypac} ne '') { + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'HTTP::ProxyPAC', + error_msg => "Cannot load module 'HTTP::ProxyPAC'."); + my ($pac, $pac_uri); + eval { + if ($options{request}->{proxypac} =~ /^(http|https):\/\//) { + $pac_uri = URI->new($options{request}->{proxypac}); + $pac = HTTP::ProxyPAC->new($pac_uri); + } else { + $pac = HTTP::ProxyPAC->new($options{request}->{proxypac}); + } + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => 'issue to load proxypac: ' . $@); + $self->{output}->option_exit(); + } + my $res = $pac->find_proxy($options{url}); + if (defined($res->direct) && $res->direct != 1) { + my $proxy_uri = URI->new($res->proxy); + $proxy_uri->userinfo($pac_uri->userinfo) if (defined($pac_uri->userinfo)); + $self->{ua}->proxy(['http', 'https'], $proxy_uri->as_string); + } + } + if (defined($options{request}->{proxyurl}) && $options{request}->{proxyurl} ne '') { + $self->{ua}->proxy(['http', 'https'], $options{request}->{proxyurl}); + } +} + +sub request { + my ($self, %options) = @_; + + my $request_options = $options{request}; + if (!defined($self->{ua})) { + $self->{ua} = centreon::plugins::backend::http::useragent->new( + keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $request_options->{timeout}, + credentials => $request_options->{credentials}, username => $request_options->{username}, password => $request_options->{password}); + if (defined($request_options->{cookies_file})) { + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'HTTP::Cookies', + error_msg => "Cannot load module 'HTTP::Cookies'."); + $self->{ua}->cookie_jar(HTTP::Cookies->new(file => $request_options->{cookies_file}, + autosave => 1)); + } + } + if (defined($request_options->{no_follow})) { + $self->{ua}->requests_redirectable(undef); + } else { + $self->{ua}->requests_redirectable([ 'GET', 'HEAD', 'POST' ]); + } + if (defined($request_options->{http_peer_addr})) { + push @LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerAddr => $request_options->{http_peer_addr}; + } + + my ($req, $url); + if (defined($request_options->{full_url})) { + $url = $request_options->{full_url}; + } elsif (defined($request_options->{port}) && $request_options->{port} =~ /^[0-9]+$/) { + $url = $request_options->{proto}. "://" . $request_options->{hostname} . ':' . $request_options->{port} . $request_options->{url_path}; + } else { + $url = $request_options->{proto}. "://" . $request_options->{hostname} . $request_options->{url_path}; + } + + my $uri = URI->new($url); + if (defined($request_options->{get_params})) { + $uri->query_form($request_options->{get_params}); + } + $req = HTTP::Request->new($request_options->{method}, $uri); + + my $content_type_forced; + foreach my $key (keys %{$request_options->{headers}}) { + if ($key !~ /content-type/i) { + $req->header($key => $request_options->{headers}->{$key}); + } else { + $content_type_forced = $request_options->{headers}->{$key}; + } + } + + if ($request_options->{method} eq 'POST') { + if (defined($content_type_forced)) { + $req->content_type($content_type_forced); + $req->content($request_options->{query_form_post}); + } else { + my $uri_post = URI->new(); + if (defined($request_options->{post_params})) { + $uri_post->query_form($request_options->{post_params}); + } + $req->content_type('application/x-www-form-urlencoded'); + $req->content($uri_post->query); + } + } + + if (defined($request_options->{credentials}) && defined($request_options->{ntlmv2})) { + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Authen::NTLM', + error_msg => "Cannot load module 'Authen::NTLM'."); + Authen::NTLM::ntlmv2(1); + } + + if (defined($request_options->{credentials}) && defined($request_options->{basic})) { + $req->authorization_basic($request_options->{username}, $request_options->{password}); + } + + $self->set_proxy(request => $request_options, url => $url); + + if (defined($request_options->{cert_pkcs12}) && $request_options->{cert_file} ne '' && $request_options->{cert_pwd} ne '') { + eval "use Net::SSL"; die $@ if $@; + $ENV{HTTPS_PKCS12_FILE} = $request_options->{cert_file}; + $ENV{HTTPS_PKCS12_PASSWORD} = $request_options->{cert_pwd}; + } + + if (defined($self->{ssl_context}) && $self->{ssl_context} ne '') { + my $context = new IO::Socket::SSL::SSL_Context(eval $self->{ssl_context}); + IO::Socket::SSL::set_default_context($context); + } + + $self->{response} = $self->{ua}->request($req); + + # Check response + my $status = 'ok'; + my $message; + + eval { + local $SIG{__WARN__} = sub { $message = $_[0]; }; + local $SIG{__DIE__} = sub { $message = $_[0]; }; + + if (defined($request_options->{critical_status}) && $request_options->{critical_status} ne '' && + eval "$request_options->{critical_status}") { + $status = 'critical'; + } elsif (defined($request_options->{warning_status}) && $request_options->{warning_status} ne '' && + eval "$request_options->{warning_status}") { + $status = 'warning'; + } elsif (defined($request_options->{unknown_status}) && $request_options->{unknown_status} ne '' && + eval "$request_options->{unknown_status}") { + $status = 'unknown'; + } + }; + if (defined($message)) { + $self->{output}->add_option_msg(short_msg => 'filter status issue: ' . $message); + $self->{output}->option_exit(); + } + + if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { + my $short_msg = $self->{response}->status_line; + if ($short_msg =~ /^401/) { + my ($authenticate) = $self->{response}->www_authenticate =~ /(\S+)/; + $short_msg .= ' (' . $authenticate . ' authentication expected)'; + } + + $self->{output}->output_add(long_msg => $self->{response}->content, debug => 1); + $self->{output}->output_add(severity => $status, + short_msg => $short_msg); + $self->{output}->display(); + $self->{output}->exit(); + } + + $self->{headers} = $self->{response}->headers(); + return $self->{response}->content; +} + +sub get_header { + my ($self, %options) = @_; + + return $self->{headers}->header($options{name}); +} + +sub get_code { + my ($self, %options) = @_; + + return $self->{response}->code(); +} + +1; + +__END__ + +=head1 NAME + +HTTP LWP backend layer. + +=head1 SYNOPSIS + +HTTP LWP backend layer. + +=head1 BACKEND LWP OPTIONS + +=over 8 + +=item B<--ssl-opt> + +Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). + +=item B<--ssl> + +Set SSL version (--ssl=TLSv1). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon/plugins/useragent.pm b/centreon/plugins/backend/http/useragent.pm similarity index 89% rename from centreon/plugins/useragent.pm rename to centreon/plugins/backend/http/useragent.pm index 5eca396e9..f9a9b419f 100644 --- a/centreon/plugins/useragent.pm +++ b/centreon/plugins/backend/http/useragent.pm @@ -1,5 +1,5 @@ # -# Copyright 2017 Centreon (http://www.centreon.com/) +# Copyright 2019 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -18,7 +18,7 @@ # limitations under the License. # -package centreon::plugins::useragent; +package centreon::plugins::backend::http::useragent; use strict; use warnings; @@ -30,7 +30,7 @@ sub new { bless $self, $class; $self = LWP::UserAgent::new(@_); - $self->agent("centreon::plugins::useragent"); + $self->agent("centreon::plugins::backend::http::useragent"); $self->{credentials} = $options{credentials} if defined($options{credentials}); $self->{username} = $options{username} if defined($options{username}); diff --git a/centreon/plugins/http.pm b/centreon/plugins/http.pm index 113d12b74..9520205f5 100644 --- a/centreon/plugins/http.pm +++ b/centreon/plugins/http.pm @@ -22,18 +22,31 @@ package centreon::plugins::http; use strict; use warnings; -use centreon::plugins::useragent; -use HTTP::Cookies; -use URI; -use IO::Socket::SSL; sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; + if (!defined($options{noptions}) || $options{noptions} != 1) { + $options{options}->add_options(arguments => { + "http-peer-addr:s" => { name => 'http_peer_addr' }, + "proxyurl:s" => { name => 'proxyurl' }, + "proxypac:s" => { name => 'proxypac' }, + "http-backend:s" => { name => 'http_backend', default => 'lwp' }, + }); + $options{options}->add_help(package => __PACKAGE__, sections => 'HTTP GLOBAL OPTIONS'); + } + + centreon::plugins::misc::mymodule_load(output => $options{output}, module => 'centreon::plugins::backend::http::lwp', + error_msg => "Cannot load module 'centreon::plugins::backend::http::lwp'."); + $self->{backend_lwp} = centreon::plugins::backend::http::lwp->new(%options); + + centreon::plugins::misc::mymodule_load(output => $options{output}, module => 'centreon::plugins::backend::http::curl', + error_msg => "Cannot load module 'centreon::plugins::backend::http::curl'."); + $self->{backend_curl} = centreon::plugins::backend::http::curl->new(%options); + $self->{output} = $options{output}; - $self->{ua} = undef; $self->{options} = { proto => 'http', url_path => '/', @@ -43,6 +56,7 @@ sub new { warning_status => undef, critical_status => undef, }; + $self->{add_headers} = {}; return $self; } @@ -65,6 +79,14 @@ sub add_header { sub check_options { my ($self, %options) = @_; + $options{request}->{http_backend} = 'lwp' + if (!defined($options{request}->{http_backend}) || $options{request}->{http_backend} eq ''); + $self->{http_backend} = $options{request}->{http_backend}; + if ($self->{http_backend} !~ /^\s*lwp|curl\s*$/i) { + $self->{output}->add_option_msg(short_msg => "Unsupported http backend specified '" . $self->{http_backend} . "'."); + $self->{output}->option_exit(); + } + if (($options{request}->{proto} ne 'http') && ($options{request}->{proto} ne 'https')) { $self->{output}->add_option_msg(short_msg => "Unsupported protocol specified '" . $self->{option_results}->{proto} . "'."); $self->{output}->option_exit(); @@ -77,12 +99,13 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used"); $self->{output}->option_exit(); } - if ((defined($options{request}->{pkcs12})) && (!defined($options{request}->{cert_file}) && !defined($options{request}->{cert_pwd}))) { + if ((defined($options{request}->{cert_pkcs12})) && (!defined($options{request}->{cert_file}) && !defined($options{request}->{cert_pwd}))) { $self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used"); $self->{output}->option_exit(); } $options{request}->{port} = $self->get_port_request(); + $options{request}->{port_force} = $self->get_port(); $options{request}->{headers} = {}; if (defined($options{request}->{header})) { @@ -98,52 +121,25 @@ sub check_options { foreach my $method (('get', 'post')) { if (defined($options{request}->{$method . '_param'})) { - $self->{$method . '_params'} = {}; + $options{request}->{$method . '_params'} = {}; foreach (@{$options{request}->{$method . '_param'}}) { if (/^([^=]+)={0,1}(.*)$/) { my $key = $1; my $value = defined($2) ? $2 : 1; - if (defined($self->{$method . '_params'}->{$key})) { - if (ref($self->{$method . '_params'}->{$key}) ne 'ARRAY') { - $self->{$method . '_params'}->{$key} = [ $self->{$method . '_params'}->{$key} ]; + if (defined($options{request}->{$method . '_params'}->{$key})) { + if (ref($options{request}->{$method . '_params'}->{$key}) ne 'ARRAY') { + $options{request}->{$method . '_params'}->{$key} = [ $options{request}->{$method . '_params'}->{$key} ]; } - push @{$self->{$method . '_params'}->{$key}}, $value; + push @{$options{request}->{$method . '_params'}->{$key}}, $value; } else { - $self->{$method . '_params'}->{$key} = $value; + $options{request}->{$method . '_params'}->{$key} = $value; } } } } } - - foreach (('unknown_status', 'warning_status', 'critical_status')) { - if (defined($options{request}->{$_})) { - $options{request}->{$_} =~ s/%\{http_code\}/\$response->code/g; - } - } - - $self->{ssl_context} = ''; - if (!defined($options{request}->{ssl_opt})) { - $options{request}->{ssl_opt} = []; - } - if (defined($options{request}->{ssl}) && $options{request}->{ssl} ne '') { - push @{$options{request}->{ssl_opt}}, 'SSL_version => ' . $options{request}->{ssl}; - } - if (defined($options{request}->{cert_file}) && !defined($options{request}->{cert_pkcs12})) { - push @{$options{request}->{ssl_opt}}, 'SSL_use_cert => 1'; - push @{$options{request}->{ssl_opt}}, 'SSL_cert_file => "' . $options{request}->{cert_file} . '"'; - push @{$options{request}->{ssl_opt}}, 'SSL_key_file => "' . $options{request}->{key_file} . '"' - if (defined($options{request}->{key_file})); - push @{$options{request}->{ssl_opt}}, 'SSL_ca_file => "' . $options{request}->{cacert_file} . '"' - if (defined($options{request}->{cacert_file})); - } - my $append = ''; - foreach (@{$options{request}->{ssl_opt}}) { - if ($_ ne '') { - $self->{ssl_context} .= $append . $_; - $append = ', '; - } - } + + $self->{'backend_' . $self->{http_backend}}->check_options(%options); } sub get_port { @@ -170,37 +166,6 @@ sub get_port_request { return $port; } -sub set_proxy { - my ($self, %options) = @_; - - if (defined($options{request}->{proxypac}) && $options{request}->{proxypac} ne '') { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'HTTP::ProxyPAC', - error_msg => "Cannot load module 'HTTP::ProxyPAC'."); - my ($pac, $pac_uri); - eval { - if ($options{request}->{proxypac} =~ /^(http|https):\/\//) { - $pac_uri = URI->new($options{request}->{proxypac}); - $pac = HTTP::ProxyPAC->new($pac_uri); - } else { - $pac = HTTP::ProxyPAC->new($options{request}->{proxypac}); - } - }; - if ($@) { - $self->{output}->add_option_msg(short_msg => 'issue to load proxypac: ' . $@); - $self->{output}->option_exit(); - } - my $res = $pac->find_proxy($options{url}); - if (defined($res->direct) && $res->direct != 1) { - my $proxy_uri = URI->new($res->proxy); - $proxy_uri->userinfo($pac_uri->userinfo) if (defined($pac_uri->userinfo)); - $self->{ua}->proxy(['http', 'https'], $proxy_uri->as_string); - } - } - if (defined($options{request}->{proxyurl}) && $options{request}->{proxyurl} ne '') { - $self->{ua}->proxy(['http', 'https'], $options{request}->{proxyurl}); - } -} - sub request { my ($self, %options) = @_; @@ -210,140 +175,58 @@ sub request { } $self->check_options(request => $request_options); - if (!defined($self->{ua})) { - $self->{ua} = centreon::plugins::useragent->new(keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $request_options->{timeout}, - credentials => $request_options->{credentials}, username => $request_options->{username}, password => $request_options->{password}); - if (defined($request_options->{cookies_file})) { - $self->{ua}->cookie_jar(HTTP::Cookies->new(file => $request_options->{cookies_file}, - autosave => 1)); - } - } - if (defined($request_options->{no_follow})) { - $self->{ua}->requests_redirectable(undef); - } else { - $self->{ua}->requests_redirectable([ 'GET', 'HEAD', 'POST' ]); - } - if (defined($request_options->{http_peer_addr})) { - push @LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerAddr => $request_options->{http_peer_addr}; - } - - my ($response, $content); - my ($req, $url); - if (defined($request_options->{full_url})) { - $url = $request_options->{full_url}; - } elsif (defined($request_options->{port}) && $request_options->{port} =~ /^[0-9]+$/) { - $url = $request_options->{proto}. "://" . $request_options->{hostname} . ':' . $request_options->{port} . $request_options->{url_path}; - } else { - $url = $request_options->{proto}. "://" . $request_options->{hostname} . $request_options->{url_path}; - } - - my $uri = URI->new($url); - if (defined($self->{get_params})) { - $uri->query_form($self->{get_params}); - } - $req = HTTP::Request->new($request_options->{method}, $uri); - - my $content_type_forced; - foreach my $key (keys %{$request_options->{headers}}) { - if ($key !~ /content-type/i) { - $req->header($key => $request_options->{headers}->{$key}); - } else { - $content_type_forced = $request_options->{headers}->{$key}; - } - } - - if ($request_options->{method} eq 'POST') { - if (defined($content_type_forced)) { - $req->content_type($content_type_forced); - $req->content($request_options->{query_form_post}); - } else { - my $uri_post = URI->new(); - if (defined($self->{post_params})) { - $uri_post->query_form($self->{post_params}); - } - $req->content_type('application/x-www-form-urlencoded'); - $req->content($uri_post->query); - } - } - - if (defined($request_options->{credentials}) && defined($request_options->{ntlmv2})) { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Authen::NTLM', - error_msg => "Cannot load module 'Authen::NTLM'."); - Authen::NTLM::ntlmv2(1); - } - - if (defined($request_options->{credentials}) && defined($request_options->{basic})) { - $req->authorization_basic($request_options->{username}, $request_options->{password}); - } - - $self->set_proxy(request => $request_options, url => $url); - - if (defined($request_options->{cert_pkcs12}) && $request_options->{cert_file} ne '' && $request_options->{cert_pwd} ne '') { - eval "use Net::SSL"; die $@ if $@; - $ENV{HTTPS_PKCS12_FILE} = $request_options->{cert_file}; - $ENV{HTTPS_PKCS12_PASSWORD} = $request_options->{cert_pwd}; - } - - if (defined($self->{ssl_context}) && $self->{ssl_context} ne '') { - my $context = new IO::Socket::SSL::SSL_Context(eval $self->{ssl_context}); - IO::Socket::SSL::set_default_context($context); - } - - $response = $self->{ua}->request($req); - - # Check response - my $status = 'ok'; - my $message; - - eval { - local $SIG{__WARN__} = sub { $message = $_[0]; }; - local $SIG{__DIE__} = sub { $message = $_[0]; }; - - if (defined($request_options->{critical_status}) && $request_options->{critical_status} ne '' && - eval "$request_options->{critical_status}") { - $status = 'critical'; - } elsif (defined($request_options->{warning_status}) && $request_options->{warning_status} ne '' && - eval "$request_options->{warning_status}") { - $status = 'warning'; - } elsif (defined($request_options->{unknown_status}) && $request_options->{unknown_status} ne '' && - eval "$request_options->{unknown_status}") { - $status = 'unknown'; - } - }; - if (defined($message)) { - $self->{output}->add_option_msg(short_msg => 'filter status issue: ' . $message); - $self->{output}->option_exit(); - } - - if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { - my $short_msg = $response->status_line; - if ($short_msg =~ /^401/) { - my ($authenticate) = $response->www_authenticate =~ /(\S+)/; - $short_msg .= ' (' . $authenticate . ' authentication expected)'; - } - - $self->{output}->output_add(long_msg => $response->content, debug => 1); - $self->{output}->output_add(severity => $status, - short_msg => $short_msg); - $self->{output}->display(); - $self->{output}->exit(); - } - - $self->{headers} = $response->headers(); - $self->{response} = $response; - return $response->content; + return $self->{'backend_' . $self->{http_backend}}->request(request => $request_options); } sub get_header { my ($self, %options) = @_; - return $self->{headers}; + return $self->{'backend_' . $self->{http_backend}}->get_header(%options); } -sub get_response { +sub get_code { my ($self, %options) = @_; - return $self->{response}; + return $self->{'backend_' . $self->{http_backend}}->get_code(); } 1; + +__END__ + +=head1 NAME + +HTTP abstraction layer. + +=head1 SYNOPSIS + +HTTP abstraction layer for lwp and curl backends + +=head1 HTTP GLOBAL OPTIONS + +=over 8 + +=item B<--http-peer-addr> + +Set the address you want to connect (Useful if hostname is only a vhost. no ip resolve) + +=item B<--proxyurl> + +Proxy URL + +=item B<--proxypac> + +Proxy pac file (can be an url or local file) + +=item B<--http-backend> + +Set the backend used (Default: 'lwp') +For curl: --http-backend=curl + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon/plugins/passwordmgr/teampass.pm b/centreon/plugins/passwordmgr/teampass.pm index 147026913..a9a798b93 100644 --- a/centreon/plugins/passwordmgr/teampass.pm +++ b/centreon/plugins/passwordmgr/teampass.pm @@ -56,7 +56,7 @@ sub new { $options{options}->add_help(package => __PACKAGE__, sections => 'TEAMPASS OPTIONS'); $self->{output} = $options{output}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options, noptions => 1); $JSON::Path::Safe = 0; return $self; diff --git a/cloud/azure/custom/api.pm b/cloud/azure/custom/api.pm index aa794fb6a..43a4fdcb7 100644 --- a/cloud/azure/custom/api.pm +++ b/cloud/azure/custom/api.pm @@ -44,27 +44,25 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "subscription:s" => { name => 'subscription' }, - "tenant:s" => { name => 'tenant' }, - "client-id:s" => { name => 'client_id' }, - "client-secret:s" => { name => 'client_secret' }, - "login-endpoint:s" => { name => 'login_endpoint' }, - "management-endpoint:s" => { name => 'management_endpoint' }, - "timeframe:s" => { name => 'timeframe' }, - "interval:s" => { name => 'interval' }, - "aggregation:s@" => { name => 'aggregation' }, - "zeroed" => { name => 'zeroed' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - }); + $options{options}->add_options(arguments => { + "subscription:s" => { name => 'subscription' }, + "tenant:s" => { name => 'tenant' }, + "client-id:s" => { name => 'client_id' }, + "client-secret:s" => { name => 'client_secret' }, + "login-endpoint:s" => { name => 'login_endpoint' }, + "management-endpoint:s" => { name => 'management_endpoint' }, + "timeframe:s" => { name => 'timeframe' }, + "interval:s" => { name => 'interval' }, + "aggregation:s@" => { name => 'aggregation' }, + "zeroed" => { name => 'zeroed' }, + "timeout:s" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{cache} = centreon::plugins::statefile->new(%options); return $self; @@ -105,8 +103,6 @@ sub check_options { } $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; $self->{timeframe} = (defined($self->{option_results}->{timeframe})) ? $self->{option_results}->{timeframe} : undef; $self->{step} = (defined($self->{option_results}->{step})) ? $self->{option_results}->{step} : undef; $self->{subscription} = (defined($self->{option_results}->{subscription})) ? $self->{option_results}->{subscription} : undef; @@ -147,8 +143,6 @@ sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; - $self->{option_results}->{ssl_opt} = $self->{ssl_opt}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; $self->{option_results}->{unknown_status} = '%{http_code} < 200 or %{http_code} >= 500'; @@ -651,10 +645,6 @@ does not return value when not defined. Set timeout in seconds (Default: 10). -=item B<--proxyurl> - -Proxy URL if any - =back =head1 DESCRIPTION diff --git a/cloud/cadvisor/restapi/custom/api.pm b/cloud/cadvisor/restapi/custom/api.pm index dd905656b..7d5c37a21 100644 --- a/cloud/cadvisor/restapi/custom/api.pm +++ b/cloud/cadvisor/restapi/custom/api.pm @@ -42,29 +42,27 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s" => { name => 'port', default => 8080 }, - "proto:s" => { name => 'proto', default => 'http' }, - "path:s" => { name => 'path', default => '/containers/docker/' }, - "credentials" => { name => 'credentials' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "timeout:s" => { name => 'timeout', default => 10 }, - "ssl:s" => { name => 'ssl' }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "cert-pwd:s" => { name => 'cert_pwd' }, - "cert-pkcs12" => { name => 'cert_pkcs12' }, - "api-version:s" => { name => 'api_version', default => 'v1.3' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s" => { name => 'port', default => 8080 }, + "proto:s" => { name => 'proto', default => 'http' }, + "path:s" => { name => 'path', default => '/containers/docker/' }, + "credentials" => { name => 'credentials' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout', default => 10 }, + "cert-file:s" => { name => 'cert_file' }, + "key-file:s" => { name => 'key_file' }, + "cacert-file:s" => { name => 'cacert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + "api-version:s" => { name => 'api_version', default => 'v1.3' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + $self->{http} = centreon::plugins::http->new(%options); + $self->{output} = $options{output}; $self->{mode} = $options{mode}; @@ -105,14 +103,15 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); $self->{output}->option_exit(); } - $self->{http} = {}; + + $self->{node_names} = []; foreach my $node_name (@{$self->{hostname}}) { if ($node_name ne '') { - $self->{http}->{$node_name} = centreon::plugins::http->new(output => $self->{output}); - $self->{option_results}->{hostname} = $node_name; - $self->{http}->{$node_name}->set_options(%{$self->{option_results}}); + push @{$self->{node_names}}, $node_name; } } + + $self->{http}->set_options(%{$self->{option_results}}); return 0; } @@ -132,7 +131,8 @@ sub get_port { sub internal_api_list_nodes { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/api/' . $self->{option_results}->{api_version} . $self->{option_results}->{path}, unknown_status => '', critical_status => '', warning_status => ''); my $nodes; @@ -153,7 +153,8 @@ sub internal_api_list_nodes { sub internal_api_info { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/api/' . $self->{option_results}->{api_version} . '/machine/', unknown_status => '', critical_status => '', warning_status => ''); my $nodes; @@ -172,7 +173,8 @@ sub internal_api_info { sub internal_api_list_containers { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/api/' . $self->{option_results}->{api_version} . $self->{option_results}->{path}, unknown_status => '', critical_status => '', warning_status => ''); my $containers = []; @@ -187,7 +189,8 @@ sub internal_api_list_containers { } foreach my $container (@{$containers_ids->{subcontainers}}) { my $json_response = JSON::XS->new->utf8->decode( - $self->{http}->{$options{node_name}}->request( + $self->{http}->request( + hostname => $options{node_name}, url_path => '/api/' . $self->{option_results}->{api_version} . '/containers/' . $container->{name} ) ); @@ -204,7 +207,8 @@ sub internal_api_list_containers { sub internal_api_get_machine_stats { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/api/' . $self->{option_results}->{api_version} . '/machine', unknown_status => '', critical_status => '', warning_status => ''); my $machine_stats; @@ -225,7 +229,8 @@ sub internal_api_get_machine_stats { sub internal_api_get_container_stats { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/api/' . $self->{option_results}->{api_version} . $self->{option_results}->{path} . '/' . $options{container_id}, unknown_status => '', critical_status => '', warning_status => ''); my $container_stats; @@ -248,7 +253,7 @@ sub api_list_containers { my ($self, %options) = @_; my $containers = {}; - foreach my $node_name (keys %{$self->{http}}) { + foreach my $node_name (@{$self->{node_names}}) { my $list_containers = $self->internal_api_list_containers(node_name => $node_name); foreach my $container (@$list_containers) { $containers->{$container->{id}} = { @@ -265,7 +270,7 @@ sub api_get_machine_stats { my ($self, %options) = @_; my $machine_stats = {}; - foreach my $node_name (keys %{$self->{http}}) { + foreach my $node_name (@{$self->{node_names}}) { $machine_stats->{$node_name} = $self->internal_api_get_machine_stats(node_name => $node_name); } return $machine_stats; @@ -275,7 +280,7 @@ sub api_list_nodes { my ($self, %options) = @_; my $nodes = {}; - foreach my $node_name (keys %{$self->{http}}) { + foreach my $node_name (@{$self->{node_names}}) { my $info_node = $self->internal_api_info(node_name => $node_name); my $list_nodes = $self->internal_api_list_nodes(node_name => $node_name); $nodes->{$node_name} = { nodes => [], @@ -367,22 +372,10 @@ Specify username for basic authentification (Mandatory if --credentials is speci Specify password for basic authentification (Mandatory if --credentials is specidied) -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--timeout> Threshold for HTTP timeout (Default: 10) -=item B<--ssl> - -Specify SSL version (example : 'sslv3', 'tlsv1'...) - =item B<--cert-file> Specify certificate to send to the webserver diff --git a/cloud/cloudfoundry/restapi/custom/api.pm b/cloud/cloudfoundry/restapi/custom/api.pm index b8d48103e..4602c4e83 100644 --- a/cloud/cloudfoundry/restapi/custom/api.pm +++ b/cloud/cloudfoundry/restapi/custom/api.pm @@ -41,26 +41,23 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "api-path:s" => { name => 'api_path' }, - "api-username:s" => { name => 'api_username' }, - "api-password:s" => { name => 'api_password' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "api-path:s" => { name => 'api_path' }, + "api-username:s" => { name => 'api_username' }, + "api-password:s" => { name => 'api_password' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -97,8 +94,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : 'cf'; $self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/v2'; $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; @@ -128,8 +123,6 @@ sub build_options_for_httplib { $self->{option_results}->{username} = $self->{username}; $self->{option_results}->{password} = $self->{password}; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; - $self->{option_results}->{ssl_opt} = $self->{ssl_opt}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -151,7 +144,6 @@ sub request_api { my $content = $self->{http}->request(method => $options{method}, url_path => $self->{api_path} . $options{url_path}, query_form_post => $options{query_form_post}, critical_status => '', warning_status => '', unknown_status => ''); - my $response = $self->{http}->get_response(); my $decoded; eval { $decoded = decode_json($content); @@ -161,7 +153,7 @@ sub request_api { $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); $self->{output}->option_exit(); } - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { $self->{output}->add_option_msg(short_msg => "Error code: " . $decoded->{error_code} . ". Description: " . $decoded->{description}); $self->{output}->option_exit(); } @@ -319,19 +311,10 @@ Authorization endpoint username (Default: 'cf') Authorization endpoint password (Default: '') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (Examples: --ssl-opt="SSL_version => TLSv1" ---ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/cloud/docker/restapi/custom/api.pm b/cloud/docker/restapi/custom/api.pm index 9f802a3a5..b277b94bd 100644 --- a/cloud/docker/restapi/custom/api.pm +++ b/cloud/docker/restapi/custom/api.pm @@ -42,33 +42,30 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s" => { name => 'port', default => 8080 }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "timeout:s" => { name => 'timeout', default => 10 }, - "ssl:s" => { name => 'ssl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "cert-pwd:s" => { name => 'cert_pwd' }, - "cert-pkcs12" => { name => 'cert_pkcs12' }, - "api-display" => { name => 'api_display' }, - "api-write-file:s" => { name => 'api_write_file' }, - "api-read-file:s" => { name => 'api_read_file' }, - "reload-cache-time:s" => { name => 'reload_cache_time', default => 300 }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s" => { name => 'port', default => 8080 }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout', default => 10 }, + "cert-file:s" => { name => 'cert_file' }, + "key-file:s" => { name => 'key_file' }, + "cacert-file:s" => { name => 'cacert_file' }, + "cert-pwd:s" => { name => 'cert_pwd' }, + "cert-pkcs12" => { name => 'cert_pkcs12' }, + "api-display" => { name => 'api_display' }, + "api-write-file:s" => { name => 'api_write_file' }, + "api-read-file:s" => { name => 'api_read_file' }, + "reload-cache-time:s" => { name => 'reload_cache_time', default => 300 }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + $self->{http} = centreon::plugins::http->new(%options); + $self->{output} = $options{output}; $self->{mode} = $options{mode}; @@ -111,14 +108,15 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); $self->{output}->option_exit(); } - $self->{http} = {}; + + $self->{node_names} = []; foreach my $node_name (@{$self->{hostname}}) { if ($node_name ne '') { - $self->{http}->{$node_name} = centreon::plugins::http->new(output => $self->{output}); - $self->{option_results}->{hostname} = $node_name; - $self->{http}->{$node_name}->set_options(%{$self->{option_results}}); + push @{$self->{node_names}}, $node_name; } } + + $self->{http}->set_options(%{$self->{option_results}}); return 0; } @@ -195,7 +193,7 @@ sub cache_containers { $containers = {}; my $datas = { last_timestamp => time(), containers => $containers }; - foreach my $node_name (keys %{$self->{http}}) { + foreach my $node_name (@{$self->{node_names}}) { my $list_containers = $self->internal_api_list_containers(node_name => $node_name); foreach my $container (@$list_containers) { $containers->{$container->{Id}} = { @@ -214,7 +212,8 @@ sub cache_containers { sub internal_api_list_nodes { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/nodes', unknown_status => '', critical_status => '', warning_status => ''); my $nodes; @@ -235,7 +234,8 @@ sub internal_api_list_nodes { sub internal_api_info { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/info', unknown_status => '', critical_status => '', warning_status => ''); my $nodes; @@ -254,7 +254,8 @@ sub internal_api_info { sub internal_api_list_containers { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/containers/json?all=true', unknown_status => '', critical_status => '', warning_status => ''); my $containers; @@ -273,7 +274,8 @@ sub internal_api_list_containers { sub internal_api_get_container_stats { my ($self, %options) = @_; - my $response = $self->{http}->{$options{node_name}}->request( + my $response = $self->{http}->request( + hostname => $options{node_name}, url_path => '/containers/' . $options{container_id} . '/stats?stream=false', unknown_status => '', critical_status => '', warning_status => ''); my $container_stats; @@ -293,7 +295,7 @@ sub api_list_containers { my ($self, %options) = @_; my $containers = {}; - foreach my $node_name (keys %{$self->{http}}) { + foreach my $node_name (@{$self->{node_names}}) { my $list_containers = $self->internal_api_list_containers(node_name => $node_name); foreach my $container (@$list_containers) { $containers->{$container->{Id}} = { @@ -311,7 +313,7 @@ sub api_list_nodes { my ($self, %options) = @_; my $nodes = {}; - foreach my $node_name (keys %{$self->{http}}) { + foreach my $node_name (@{$self->{node_names}}) { my $info_node = $self->internal_api_info(node_name => $node_name); my $list_nodes = $self->internal_api_list_nodes(node_name => $node_name); $nodes->{$node_name} = { nodes => [], @@ -410,22 +412,10 @@ Specify this option if you access server-status page over hidden basic authentic (Use with --credentials) -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--timeout> Threshold for HTTP timeout (Default: 10) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--cert-file> Specify certificate to send to the webserver diff --git a/cloud/ibm/softlayer/custom/xmlapi.pm b/cloud/ibm/softlayer/custom/xmlapi.pm index 713dd00b5..4546eb555 100644 --- a/cloud/ibm/softlayer/custom/xmlapi.pm +++ b/cloud/ibm/softlayer/custom/xmlapi.pm @@ -40,24 +40,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "url-path:s" => { name => 'url_path' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "api-username:s" => { name => 'api_username' }, - "api-key:s" => { name => 'api_key' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "url-path:s" => { name => 'url_path' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "timeout:s" => { name => 'timeout' }, + "api-username:s" => { name => 'api_username' }, + "api-key:s" => { name => 'api_key' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'XMLAPI OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -92,8 +89,6 @@ sub check_options { $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/soap/v3'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; if (!defined($self->{option_results}->{api_username}) || $self->{option_results}->{api_username} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --api-username option."); @@ -114,7 +109,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -238,18 +232,10 @@ Set API username Set API Key -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/cloud/kubernetes/restapi/custom/api.pm b/cloud/kubernetes/restapi/custom/api.pm index 93fdf90ad..d5649817f 100644 --- a/cloud/kubernetes/restapi/custom/api.pm +++ b/cloud/kubernetes/restapi/custom/api.pm @@ -48,16 +48,14 @@ sub new { "port:s" => { name => 'port' }, "proto:s" => { name => 'proto' }, "token:s" => { name => 'token' }, - "proxyurl:s" => { name => 'proxyurl' }, "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -167,9 +165,8 @@ sub request_api { $self->{url_path} . $options{url_path} . "'", debug => 1); my $content = $self->{http}->request(url_path => $self->{url_path} . $options{url_path}); - my $response = $self->{http}->get_response(); - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { my $decoded; eval { $decoded = JSON::XS->new->utf8->decode($content); @@ -185,7 +182,7 @@ sub request_api { $self->{output}->option_exit(); } else { $self->{output}->output_add(long_msg => "Error message : " . $decoded, debug => 1); - $self->{output}->add_option_msg(short_msg => "API return error code '" . $response->code() . "' (add --debug option for detailed message)"); + $self->{output}->add_option_msg(short_msg => "API return error code '" . $self->{http}->get_code() . "' (add --debug option for detailed message)"); $self->{output}->option_exit(); } } @@ -232,18 +229,10 @@ API port (Default: 443) Specify https if needed (Default: 'https') -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL option (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/cloud/microsoft/office365/custom/graphapi.pm b/cloud/microsoft/office365/custom/graphapi.pm index a78f0f29c..8849d7995 100644 --- a/cloud/microsoft/office365/custom/graphapi.pm +++ b/cloud/microsoft/office365/custom/graphapi.pm @@ -46,22 +46,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "tenant:s" => { name => 'tenant' }, - "client-id:s" => { name => 'client_id' }, - "client-secret:s" => { name => 'client_secret' }, - "login-endpoint:s" => { name => 'login_endpoint' }, - "graph-endpoint:s" => { name => 'graph_endpoint' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - }); + $options{options}->add_options(arguments => { + "tenant:s" => { name => 'tenant' }, + "client-id:s" => { name => 'client_id' }, + "client-secret:s" => { name => 'client_secret' }, + "login-endpoint:s" => { name => 'login_endpoint' }, + "graph-endpoint:s" => { name => 'graph_endpoint' }, + "timeout:s" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{cache} = centreon::plugins::statefile->new(%options); return $self; @@ -98,8 +96,6 @@ sub check_options { $self->{login_endpoint} = (defined($self->{option_results}->{login_endpoint})) ? $self->{option_results}->{login_endpoint} : 'https://login.microsoftonline.com'; $self->{graph_endpoint} = (defined($self->{option_results}->{graph_endpoint})) ? $self->{option_results}->{graph_endpoint} : 'https://graph.microsoft.com'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; if (!defined($self->{tenant}) || $self->{tenant} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --tenant option."); @@ -123,8 +119,6 @@ sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; - $self->{option_results}->{ssl_opt} = $self->{ssl_opt}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; $self->{option_results}->{unknown_status} = ''; @@ -202,9 +196,8 @@ sub request_api_json { #so lame for now $self->{output}->output_add(long_msg => "URL: '" . $local_options{full_url} . "'", debug => 1); my $content = $self->{http}->request(%local_options); - my $response = $self->{http}->get_response(); - if ($response->code() == 429) { + if ($self->{http}->get_code() == 429) { last; } @@ -243,9 +236,8 @@ sub request_api_csv { $self->{output}->output_add(long_msg => "URL: '" . $options{full_url} . "'", debug => 1); my $content = $self->{http}->request(%options); - my $response = $self->{http}->get_response(); - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { my $decoded; eval { $decoded = JSON::XS->new->utf8->decode($content); @@ -488,10 +480,6 @@ Set Office 365 graph endpoint URL (Default: 'https://graph.microsoft.com') Set timeout in seconds (Default: 10). -=item B<--proxyurl> - -Proxy URL if any - =back =head1 DESCRIPTION diff --git a/cloud/microsoft/office365/custom/managementapi.pm b/cloud/microsoft/office365/custom/managementapi.pm index 083fc2bb7..01d2433e1 100644 --- a/cloud/microsoft/office365/custom/managementapi.pm +++ b/cloud/microsoft/office365/custom/managementapi.pm @@ -44,22 +44,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "tenant:s" => { name => 'tenant' }, - "client-id:s" => { name => 'client_id' }, - "client-secret:s" => { name => 'client_secret' }, - "login-endpoint:s" => { name => 'login_endpoint' }, - "management-endpoint:s" => { name => 'management_endpoint' }, - "timeout:s" => { name => 'timeout' }, - "proxyurl:s" => { name => 'proxyurl' }, - }); + $options{options}->add_options(arguments => { + "tenant:s" => { name => 'tenant' }, + "client-id:s" => { name => 'client_id' }, + "client-secret:s" => { name => 'client_secret' }, + "login-endpoint:s" => { name => 'login_endpoint' }, + "management-endpoint:s" => { name => 'management_endpoint' }, + "timeout:s" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{cache} = centreon::plugins::statefile->new(%options); return $self; @@ -96,8 +94,6 @@ sub check_options { $self->{login_endpoint} = (defined($self->{option_results}->{login_endpoint})) ? $self->{option_results}->{login_endpoint} : 'https://login.windows.net'; $self->{management_endpoint} = (defined($self->{option_results}->{management_endpoint})) ? $self->{option_results}->{management_endpoint} : 'https://manage.office.com'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; if (!defined($self->{tenant}) || $self->{tenant} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --tenant option."); @@ -121,8 +117,6 @@ sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; - $self->{option_results}->{ssl_opt} = $self->{ssl_opt}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; $self->{option_results}->{unknown_status} = ''; @@ -291,10 +285,6 @@ Set Office 365 management endpoint URL (Default: 'https://manage.office.com') Set timeout in seconds (Default: 10). -=item B<--proxyurl> - -Proxy URL if any - =back =head1 DESCRIPTION diff --git a/cloud/ovh/restapi/custom/api.pm b/cloud/ovh/restapi/custom/api.pm index 2af49918b..30abc293e 100644 --- a/cloud/ovh/restapi/custom/api.pm +++ b/cloud/ovh/restapi/custom/api.pm @@ -46,22 +46,19 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "ovh-type:s@" => { name => 'ovh_type' }, - "ovh-application-key:s@" => { name => 'ovh_application_key' }, - "ovh-application-secret:s@" => { name => 'ovh_application_secret' }, - "ovh-consumer-key:s@" => { name => 'ovh_consumer_key' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "ovh-type:s@" => { name => 'ovh_type' }, + "ovh-application-key:s@" => { name => 'ovh_application_key' }, + "ovh-application-secret:s@" => { name => 'ovh_application_secret' }, + "ovh-consumer-key:s@" => { name => 'ovh_consumer_key' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -102,7 +99,6 @@ sub check_options { $self->{ovh_application_secret} = (defined($self->{option_results}->{ovh_application_secret})) ? shift(@{$self->{option_results}->{ovh_application_secret}}) : undef; $self->{ovh_consumer_key} = (defined($self->{option_results}->{ovh_consumer_key})) ? shift(@{$self->{option_results}->{ovh_consumer_key}}) : undef; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{ovh_application_key})) { $self->{output}->add_option_msg(short_msg => "Need to specify --ovh-application-key option."); @@ -129,7 +125,6 @@ sub build_options_for_httplib { my ($self, %options) = @_; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub settings { @@ -188,8 +183,7 @@ sub get { my $response = $self->{http}->request(full_url => $map_ovh_type{uc($self->{ovh_type})} . $options{path}, hostname => '', critical_status => '', warning_status => ''); - my $headers = $self->{http}->get_header(); - my $client_warning = $headers->header('Client-Warning'); + my ($client_warning) = $self->{http}->get_header(name => 'Client-Warning'); if (defined($client_warning) && $client_warning eq 'Internal response') { $self->{output}->add_option_msg(short_msg => "Internal LWP::UserAgent error: $response"); $self->{output}->option_exit(); @@ -243,18 +237,10 @@ OVH API applicationSecret OVH API consumerKey -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/cloud/prometheus/restapi/custom/api.pm b/cloud/prometheus/restapi/custom/api.pm index df5a2216f..266d1fda9 100644 --- a/cloud/prometheus/restapi/custom/api.pm +++ b/cloud/prometheus/restapi/custom/api.pm @@ -42,29 +42,26 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "url-path:s" => { name => 'url_path' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "header:s@" => { name => 'header' }, - "timeframe:s" => { name => 'timeframe' }, - "step:s" => { name => 'step' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "url-path:s" => { name => 'url_path' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "header:s@" => { name => 'header' }, + "timeframe:s" => { name => 'timeframe' }, + "step:s" => { name => 'step' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -303,18 +300,10 @@ Specify this option if you access the API over hidden basic authentication or yo (Use with --credentials) -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL option (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--header> Set HTTP header (Can be multiple, example: --header='Authorization:Bearer ABCD') diff --git a/docs/en/developer/guide.rst b/docs/en/developer/guide.rst index 2037e55af..ca7cf0518 100644 --- a/docs/en/developer/guide.rst +++ b/docs/en/developer/guide.rst @@ -1255,7 +1255,7 @@ We suppose these options are defined : .. code-block:: perl - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(output => $self->{output}, options => $self->{options}); $self->{http}->set_options(%{$self->{option_results}}); my $webcontent = $self->{http}->request(); print $webcontent; diff --git a/docs/fr/developer/guide.rst b/docs/fr/developer/guide.rst index 98c98d6cf..1ad51596b 100644 --- a/docs/fr/developer/guide.rst +++ b/docs/fr/developer/guide.rst @@ -1243,7 +1243,7 @@ Nous supposons que ces options sont définies : .. code-block:: perl - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(output => $self->{output}, options => $self->{options}); $self->{http}->set_options(%{$self->{option_results}}); my $webcontent = $self->{http}->request(); print $webcontent; diff --git a/hardware/sensors/sensormetrix/em01/web/mode/contact.pm b/hardware/sensors/sensormetrix/em01/web/mode/contact.pm index 21963cf7b..65d7cbe43 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/contact.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/contact.pm @@ -32,8 +32,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { + $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "port:s" => { name => 'port', }, "proto:s" => { name => 'proto' }, @@ -42,15 +41,13 @@ sub new { "basic" => { name => 'basic' }, "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, "warning" => { name => 'warning' }, "critical" => { name => 'critical' }, "closed" => { name => 'closed' }, "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + }); $self->{status} = { closed => 'ok', opened => 'ok' }; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -112,10 +109,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -148,10 +141,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning if door is opened (can set --close for closed door) diff --git a/hardware/sensors/sensormetrix/em01/web/mode/flood.pm b/hardware/sensors/sensormetrix/em01/web/mode/flood.pm index c73364b09..f63a5bf85 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/flood.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/flood.pm @@ -32,25 +32,22 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "warning" => { name => 'warning' }, - "critical" => { name => 'critical' }, - "dry" => { name => 'dry' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "warning" => { name => 'warning' }, + "critical" => { name => 'critical' }, + "dry" => { name => 'dry' }, + "timeout:s" => { name => 'timeout' }, + }); $self->{status} = { dry => 'ok', wet => 'ok' }; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -112,10 +109,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -148,10 +141,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning if flood sensor is wet (can set --dry for dry sensor) diff --git a/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm b/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm index 85583d4d8..4bc058897 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/humidity.pm @@ -32,23 +32,20 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/index.htm?em" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/index.htm?em" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -113,10 +110,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -149,10 +142,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for Humidity diff --git a/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm b/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm index a714ab4f3..021fb8642 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/illumination.pm @@ -32,8 +32,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { + $options{options}->add_options(arguments => { "hostname:s" => { name => 'hostname' }, "port:s" => { name => 'port', }, "proto:s" => { name => 'proto' }, @@ -42,13 +41,11 @@ sub new { "basic" => { name => 'basic' }, "username:s" => { name => 'username' }, "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -113,10 +110,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -149,10 +142,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for Illumination diff --git a/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm b/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm index fd9528309..770171e59 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/temperature.pm @@ -32,23 +32,20 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/index.htm?em" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/index.htm?em" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -112,10 +109,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -148,10 +141,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for Temperature diff --git a/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm b/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm index 9a5acec4f..3eb3586d5 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/thermistor.pm @@ -32,23 +32,20 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/index.htm?eR" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/index.htm?eR" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -112,10 +109,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -148,10 +141,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for Thermistor Temperature diff --git a/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm b/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm index 4c8cd8803..c8365d86b 100644 --- a/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm +++ b/hardware/sensors/sensormetrix/em01/web/mode/voltage.pm @@ -32,23 +32,20 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/index.htm?ev" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', }, + "proto:s" => { name => 'proto' }, + "urlpath:s" => { name => 'url_path', default => "/index.htm?ev" }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -113,10 +110,6 @@ IP Addr/FQDN of the webserver host Port used by Apache -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -149,10 +142,6 @@ Specify this option if you access server-status page over hidden basic authentic Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--warning> Warning Threshold for Voltage diff --git a/hardware/server/hp/ilo/xmlapi/custom/api.pm b/hardware/server/hp/ilo/xmlapi/custom/api.pm index a8c4683c2..ac0266fc3 100644 --- a/hardware/server/hp/ilo/xmlapi/custom/api.pm +++ b/hardware/server/hp/ilo/xmlapi/custom/api.pm @@ -41,16 +41,15 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "port:s" => { name => 'port', default => 443 }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - 'ssl-opt:s%' => { name => 'ssl_opt' }, - "force-ilo3" => { name => 'force_ilo3' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "timeout:s" => { name => 'timeout', default => 30 }, + "port:s" => { name => 'port', default => 443 }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + 'ssl-opt:s%' => { name => 'ssl_opt' }, + "force-ilo3" => { name => 'force_ilo3' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'XML API OPTIONS', once => 1); diff --git a/network/cisco/prime/restapi/custom/api.pm b/network/cisco/prime/restapi/custom/api.pm index d36947b3e..d22f879da 100644 --- a/network/cisco/prime/restapi/custom/api.pm +++ b/network/cisco/prime/restapi/custom/api.pm @@ -40,24 +40,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "url-path:s@" => { name => 'url_path' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "url-path:s@" => { name => 'url_path' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -102,7 +99,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -123,7 +119,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -233,18 +228,10 @@ Storeonce username. Storeonce password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/network/cisco/vcs/restapi/custom/xmlapi.pm b/network/cisco/vcs/restapi/custom/xmlapi.pm index d8cbeeb88..2605d38fa 100644 --- a/network/cisco/vcs/restapi/custom/xmlapi.pm +++ b/network/cisco/vcs/restapi/custom/xmlapi.pm @@ -40,24 +40,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "url-path:s" => { name => 'url_path' }, - "port:s" => { name => 'port' }, - "proto:s" => { name => 'proto' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "url-path:s" => { name => 'url_path' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'XMLAPI OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -94,8 +91,6 @@ sub check_options { $self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/getxml?location='; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; - $self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef; if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --hostname option."); @@ -124,7 +119,6 @@ sub build_options_for_httplib { $self->{option_results}->{password} = $self->{password}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -220,18 +214,10 @@ Set API username Set API password -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL options if needed (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/network/freebox/restapi/custom/api.pm b/network/freebox/restapi/custom/api.pm index 7a20b5b8e..11f066f4a 100644 --- a/network/freebox/restapi/custom/api.pm +++ b/network/freebox/restapi/custom/api.pm @@ -41,23 +41,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "freebox-app-id:s@" => { name => 'freebox_app_id' }, - "freebox-app-token:s@" => { name => 'freebox_app_token' }, - "freebox-api-version:s@" => { name => 'freebox_api_version', }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "resolution:s@" => { name => 'resolution' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "freebox-app-id:s@" => { name => 'freebox_app_id' }, + "freebox-app-token:s@" => { name => 'freebox_app_token' }, + "freebox-api-version:s@" => { name => 'freebox_api_version', }, + "timeout:s@" => { name => 'timeout' }, + "resolution:s@" => { name => 'resolution' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{session_token} = undef; @@ -95,7 +92,6 @@ sub check_options { $self->{freebox_app_token} = (defined($self->{option_results}->{freebox_app_token})) ? shift(@{$self->{option_results}->{freebox_app_token}}) : undef; $self->{freebox_api_version} = (defined($self->{option_results}->{freebox_api_version})) ? shift(@{$self->{option_results}->{freebox_api_version}}) : 'v4'; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; $self->{resolution} = (defined($self->{option_results}->{resolution})) ? shift(@{$self->{option_results}->{resolution}}) : 300; if (!defined($self->{hostname})) { @@ -125,7 +121,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 80; $self->{option_results}->{proto} = 'http'; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub settings { @@ -143,8 +138,7 @@ sub settings { sub manage_response { my ($self, %options) = @_; - my $response = $self->{http}->get_response(); - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { $self->{output}->add_option_msg(short_msg => "Connection issue: " . $options{content}); $self->{output}->option_exit(); } @@ -286,18 +280,10 @@ Freebox App Token. Freebox API version (Default: 'v4'). -=item B<--proxyurl> - -Proxy URL if any. - =item B<--timeout> Set HTTP timeout in seconds (Default: '10'). -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--resolution> Selected data performance resolution in seconds (Default: '300'). diff --git a/notification/foxbox/mode/alert.pm b/notification/foxbox/mode/alert.pm index a883ec499..38749a61d 100644 --- a/notification/foxbox/mode/alert.pm +++ b/notification/foxbox/mode/alert.pm @@ -32,21 +32,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options( - arguments => { - "foxbox-username:s" => { name => 'foxbox_username', default => 'centreon' }, - "foxbox-password:s" => { name => 'foxbox_password' }, - "from:s" => { name => 'from', default => 'centreon' }, - "proto:s" => { name => 'proto', default => 'http' }, - "urlpath:s" => { name => 'url_path', default => '/source/send_sms.php' }, - "phonenumber:s" => { name => 'phonenumber' }, - "hostname:s" => { name => 'hostname' }, - "texto:s" => { name => 'texto' }, - "timeout:s" => { name => 'timeout', default => 10 }, - } - ); + $options{options}->add_options(arguments => { + "foxbox-username:s" => { name => 'foxbox_username', default => 'centreon' }, + "foxbox-password:s" => { name => 'foxbox_password' }, + "from:s" => { name => 'from', default => 'centreon' }, + "proto:s" => { name => 'proto', default => 'http' }, + "urlpath:s" => { name => 'url_path', default => '/source/send_sms.php' }, + "phonenumber:s" => { name => 'phonenumber' }, + "hostname:s" => { name => 'hostname' }, + "texto:s" => { name => 'texto' }, + "timeout:s" => { name => 'timeout', default => 10 }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } diff --git a/notification/highsms/mode/alert.pm b/notification/highsms/mode/alert.pm index 7ecf3deb2..34f5389c1 100644 --- a/notification/highsms/mode/alert.pm +++ b/notification/highsms/mode/alert.pm @@ -33,23 +33,19 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => 443 }, - "proto:s" => { name => 'proto', default => 'https' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "phonenumber:s" => { name => 'phonenumber' }, - "message:s" => { name => 'message' }, - "sender:s" => { name => 'sender', default => 'API_HIGHSMS' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port', default => 443 }, + "proto:s" => { name => 'proto', default => 'https' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "phonenumber:s" => { name => 'phonenumber' }, + "message:s" => { name => 'message' }, + "sender:s" => { name => 'sender', default => 'API_HIGHSMS' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -133,14 +129,6 @@ Port used by HighSMS API. (Default: 443) Specify http or https protocol. (Default: https) -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--username> Specify username for API authentification. @@ -153,10 +141,6 @@ Specify password for API authentification. Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--phonenumber> Specify phone number. diff --git a/notification/ovhsms/mode/alert.pm b/notification/ovhsms/mode/alert.pm index fce312a7e..8ac832aba 100644 --- a/notification/ovhsms/mode/alert.pm +++ b/notification/ovhsms/mode/alert.pm @@ -33,28 +33,24 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'www.ovh.com' }, - "port:s" => { name => 'port', default => 443 }, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => "/cgi-bin/sms/http2sms.cgi" }, - "account:s" => { name => 'account' }, - "login:s" => { name => 'login' }, - "password:s" => { name => 'password' }, - "from:s" => { name => 'from'}, - "to:s" => { name => 'to' }, - "message:s" => { name => 'message' }, - "class:s" => { name => 'class', default => 1 }, - "nostop:s" => { name => 'nostop', default => 1 }, - "smscoding:s" => { name => 'smscoding', default => 1 }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'www.ovh.com' }, + "port:s" => { name => 'port', default => 443 }, + "proto:s" => { name => 'proto', default => 'https' }, + "urlpath:s" => { name => 'url_path', default => "/cgi-bin/sms/http2sms.cgi" }, + "account:s" => { name => 'account' }, + "login:s" => { name => 'login' }, + "password:s" => { name => 'password' }, + "from:s" => { name => 'from'}, + "to:s" => { name => 'to' }, + "message:s" => { name => 'message' }, + "class:s" => { name => 'class', default => 1 }, + "nostop:s" => { name => 'nostop', default => 1 }, + "smscoding:s" => { name => 'smscoding', default => 1 }, + "timeout:s" => { name => 'timeout' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -157,14 +153,6 @@ Specify https if needed (Default: 'https'). Set path to the SMS API (Default: '/cgi-bin/sms/http2sms.cgi'). -=item B<--proxyurl> - -Proxy URL if any. - -=item B<--proxypac> - -Proxy pac file (can be an url or local file). - =item B<--account> Specify SMS Account for API authentification. @@ -205,10 +193,6 @@ Specify the coding of message. (Default : '1'). Threshold for HTTP timeout -=item B<--ssl-opt> - -Set SSL options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =cut diff --git a/notification/slack/mode/alert.pm b/notification/slack/mode/alert.pm index fd143a80b..aa1266ecc 100644 --- a/notification/slack/mode/alert.pm +++ b/notification/slack/mode/alert.pm @@ -45,36 +45,32 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "slack-url:s" => { name => 'slack_url' }, - "slack-channel:s" => { name => 'slack_channel' }, - "slack-username:s" => { name => 'slack_username' }, - "host-name:s" => { name => 'host_name' }, - "host-state:s" => { name => 'host_state' }, - "host-output:s" => { name => 'host_output' }, - "service-description:s" => { name => 'service_description' }, - "service-state:s" => { name => 'service_state' }, - "service-output:s" => { name => 'service_output' }, - "slack-color:s" => { name => 'slack_color' }, - "slack-emoji:s" => { name => 'slack_emoji', }, - "graph-url:s" => { name => 'graph_url' }, - "priority:s" => { name => 'priority' }, - "zone:s" => { name => 'zone' }, - "link-url:s" => { name => 'link_url' }, - "centreon-url:s" => { name => 'centreon_url' }, - "centreon-token:s" => { name => 'centreon_token' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "ntlm" => { name => 'ntlm' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $options{options}->add_options(arguments => { + "slack-url:s" => { name => 'slack_url' }, + "slack-channel:s" => { name => 'slack_channel' }, + "slack-username:s" => { name => 'slack_username' }, + "host-name:s" => { name => 'host_name' }, + "host-state:s" => { name => 'host_state' }, + "host-output:s" => { name => 'host_output' }, + "service-description:s" => { name => 'service_description' }, + "service-state:s" => { name => 'service_state' }, + "service-output:s" => { name => 'service_output' }, + "slack-color:s" => { name => 'slack_color' }, + "slack-emoji:s" => { name => 'slack_emoji', }, + "graph-url:s" => { name => 'graph_url' }, + "priority:s" => { name => 'priority' }, + "zone:s" => { name => 'zone' }, + "link-url:s" => { name => 'link_url' }, + "centreon-url:s" => { name => 'centreon_url' }, + "centreon-token:s" => { name => 'centreon_token' }, + "credentials" => { name => 'credentials' }, + "basic" => { name => 'basic' }, + "ntlm" => { name => 'ntlm' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + }); + $self->{http} = centreon::plugins::http->new(%options); $self->{payload_attachment} = { fields => [] }; return $self; @@ -318,14 +314,6 @@ Specify the graph url (Example: %{centreon_url}/include/views/graphs/generateGra Specify the link url (Example: %{centreon_url}/main.php?p=20201&o=svc&host_search=%{host_name}&svc_search=%{service_description}) -=item B<--proxyurl> - -Proxy URL - -=item B<--proxypac> - -Proxy pac file (can be an url or local file) - =item B<--credentials> Specify this option if you access webpage with authentication @@ -350,10 +338,6 @@ Specify this option if you access webpage over hidden basic authentication or yo Threshold for HTTP timeout (Default: 5) -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =cut diff --git a/notification/telegram/mode/alert.pm b/notification/telegram/mode/alert.pm index fa241daf4..996991ec3 100644 --- a/notification/telegram/mode/alert.pm +++ b/notification/telegram/mode/alert.pm @@ -45,31 +45,27 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname', default => 'api.telegram.org' }, - "port:s" => { name => 'port', default => 443 }, - "proto:s" => { name => 'proto', default => 'https' }, - "urlpath:s" => { name => 'url_path', default => "/sendMessage" }, - "chat-id:s" => { name => 'chat_id' }, - "bot-token:s" => { name => 'bot_token' }, - "host-name:s" => { name => 'host_name' }, - "host-state:s" => { name => 'host_state' }, - "host-output:s" => { name => 'host_output' }, - "service-description:s" => { name => 'service_description' }, - "service-state:s" => { name => 'service_state' }, - "service-output:s" => { name => 'service_output' }, - "graph-url:s" => { name => 'graph_url' }, - "link-url:s" => { name => 'link_url' }, - "centreon-url:s" => { name => 'centreon_url' }, - "centreon-token:s" => { name => 'centreon_token' }, - "proxyurl:s" => { name => 'proxyurl' }, - "proxypac:s" => { name => 'proxypac' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname', default => 'api.telegram.org' }, + "port:s" => { name => 'port', default => 443 }, + "proto:s" => { name => 'proto', default => 'https' }, + "urlpath:s" => { name => 'url_path', default => "/sendMessage" }, + "chat-id:s" => { name => 'chat_id' }, + "bot-token:s" => { name => 'bot_token' }, + "host-name:s" => { name => 'host_name' }, + "host-state:s" => { name => 'host_state' }, + "host-output:s" => { name => 'host_output' }, + "service-description:s" => { name => 'service_description' }, + "service-state:s" => { name => 'service_state' }, + "service-output:s" => { name => 'service_output' }, + "graph-url:s" => { name => 'graph_url' }, + "link-url:s" => { name => 'link_url' }, + "centreon-url:s" => { name => 'centreon_url' }, + "centreon-token:s" => { name => 'centreon_token' }, + "timeout:s" => { name => 'timeout' }, + }); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -230,14 +226,6 @@ Use Telegram CLI for getting Chat ID Telegram Bot Token (Check Telegram Doc for Creating Bot) https://core.telegram.org/bots#3-how-do-i-create-a-bot -=item B<--proxyurl> - -Proxy URL if any. - -=item B<--proxypac> - -Proxy pac file (can be an url or local file). - =item B<--host-state> Specify host server state for the alert. @@ -282,10 +270,6 @@ Specify the link url (Example: %{centreon_url}/main.php?p=20201&o=svc&host_searc Threshold for HTTP timeout. -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =cut diff --git a/storage/emc/vplex/restapi/custom/vplexapi.pm b/storage/emc/vplex/restapi/custom/vplexapi.pm index 0dbb29e10..8566866de 100644 --- a/storage/emc/vplex/restapi/custom/vplexapi.pm +++ b/storage/emc/vplex/restapi/custom/vplexapi.pm @@ -44,21 +44,18 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "vplex-username:s@" => { name => 'vplex_username' }, - "vplex-password:s@" => { name => 'vplex_password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "vplex-username:s@" => { name => 'vplex_username' }, + "vplex-password:s@" => { name => 'vplex_password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -100,7 +97,6 @@ sub check_options { $self->{vplex_username} = (defined($self->{option_results}->{vplex_username})) ? shift(@{$self->{option_results}->{vplex_username}}) : ''; $self->{vplex_password} = (defined($self->{option_results}->{vplex_password})) ? shift(@{$self->{option_results}->{vplex_password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -121,7 +117,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 443; $self->{option_results}->{proto} = 'https'; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub settings { @@ -213,18 +208,10 @@ Vplex username. Vplex password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/storage/emc/xtremio/restapi/custom/xtremioapi.pm b/storage/emc/xtremio/restapi/custom/xtremioapi.pm index 19ae0f1b3..414918145 100644 --- a/storage/emc/xtremio/restapi/custom/xtremioapi.pm +++ b/storage/emc/xtremio/restapi/custom/xtremioapi.pm @@ -41,22 +41,19 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "xtremio-username:s@" => { name => 'xtremio_username' }, - "xtremio-password:s@" => { name => 'xtremio_password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "reload-cache-time:s" => { name => 'reload_cache_time' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "xtremio-username:s@" => { name => 'xtremio_username' }, + "xtremio-password:s@" => { name => 'xtremio_password' }, + "timeout:s@" => { name => 'timeout' }, + "reload-cache-time:s" => { name => 'reload_cache_time' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); $self->{statefile_cache_cluster} = centreon::plugins::statefile->new(%options); return $self; @@ -92,7 +89,6 @@ sub check_options { $self->{xtremio_username} = (defined($self->{option_results}->{xtremio_username})) ? shift(@{$self->{option_results}->{xtremio_username}}) : ''; $self->{xtremio_password} = (defined($self->{option_results}->{xtremio_password})) ? shift(@{$self->{option_results}->{xtremio_password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; $self->{reload_cache_time} = (defined($self->{option_results}->{reload_cache_time})) ? shift(@{$self->{option_results}->{reload_cache_time}}) : 180; if (!defined($self->{hostname})) { @@ -121,7 +117,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 443; $self->{option_results}->{proto} = 'https'; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub settings { @@ -277,18 +272,10 @@ Xtremio username. Xtremio password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--reload-cache-time> Time in seconds before reloading cache file (default: 180). diff --git a/storage/hp/p2000/xmlapi/custom.pm b/storage/hp/p2000/xmlapi/custom.pm index 765959de8..51cdb979c 100644 --- a/storage/hp/p2000/xmlapi/custom.pm +++ b/storage/hp/p2000/xmlapi/custom.pm @@ -45,21 +45,20 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "urlpath:s@" => { name => 'url_path' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "urlpath:s@" => { name => 'url_path' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'P2000 OPTIONS', once => 1); + $self->{http} = centreon::plugins::http->new(%options); + $self->{output} = $options{output}; $self->{mode} = $options{mode}; @@ -108,7 +107,6 @@ sub check_options { $self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : undef; $self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'http'; $self->{url_path} = (defined($self->{option_results}->{url_path})) ? shift(@{$self->{option_results}->{url_path}}) : '/api/'; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -134,7 +132,6 @@ sub build_options_for_httplib { $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; $self->{option_results}->{url_path} = $self->{url_path}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub check_login { @@ -252,7 +249,6 @@ sub login { my ($self, %options) = @_; $self->build_options_for_httplib(); - $self->{http} = centreon::plugins::http->new(output => $self->{output}); $self->{http}->set_options(%{$self->{option_results}}); # Login First @@ -285,10 +281,6 @@ HP p2000 Hostname. Port used -=item B<--proxyurl> - -Proxy URL if any - =item B<--proto> Specify https if needed @@ -309,14 +301,10 @@ Password to connect. Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION B. -=cut \ No newline at end of file +=cut diff --git a/storage/hp/storeonce/restapi/custom/api.pm b/storage/hp/storeonce/restapi/custom/api.pm index 76dc0fd08..95a225f22 100644 --- a/storage/hp/storeonce/restapi/custom/api.pm +++ b/storage/hp/storeonce/restapi/custom/api.pm @@ -40,21 +40,18 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -89,7 +86,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -110,7 +106,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 443; $self->{option_results}->{proto} = 'https'; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -171,18 +166,10 @@ Storeonce username. Storeonce password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/storage/kaminario/restapi/custom/api.pm b/storage/kaminario/restapi/custom/api.pm index c4353f967..acfd96278 100644 --- a/storage/kaminario/restapi/custom/api.pm +++ b/storage/kaminario/restapi/custom/api.pm @@ -40,22 +40,19 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "resolution:s@" => { name => 'resolution' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + "resolution:s@" => { name => 'resolution' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -90,7 +87,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; $self->{resolution} = (defined($self->{option_results}->{resolution})) ? shift(@{$self->{option_results}->{resolution}}) : '5m'; if (!defined($self->{hostname})) { @@ -112,7 +108,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 443; $self->{option_results}->{proto} = 'https'; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; @@ -133,7 +128,6 @@ sub get_performance { $self->settings(); my $content = $self->{http}->request(url_path => '/api/v2' . $options{path} . '&__resolution=' . $self->{resolution}, critical_status => '', warning_status => ''); - my $response = $self->{http}->get_response(); my $decoded; eval { @@ -144,7 +138,7 @@ sub get_performance { $self->{output}->option_exit(); } - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{message}); $self->{output}->option_exit(); } @@ -180,18 +174,10 @@ Kaminario username. Kaminario password. -=item B<--proxyurl> - -Proxy URL if any. - =item B<--timeout> Set HTTP timeout in seconds (Default: '10'). -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--resolution> Selected data performance resolution (Default: '5m'). diff --git a/storage/netapp/restapi/custom/restapi.pm b/storage/netapp/restapi/custom/restapi.pm index 099b01511..c35eb7353 100644 --- a/storage/netapp/restapi/custom/restapi.pm +++ b/storage/netapp/restapi/custom/restapi.pm @@ -41,25 +41,21 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s@" => { name => 'hostname' }, - "url-path:s@" => { name => 'url_path' }, - "port:s@" => { name => 'port' }, - "proto:s@" => { name => 'proto' }, - "username:s@" => { name => 'username' }, - "password:s@" => { name => 'password' }, - "proxyurl:s@" => { name => 'proxyurl' }, - "timeout:s@" => { name => 'timeout' }, - "ssl:s@" => { name => 'ssl' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - }); + $options{options}->add_options(arguments => { + "hostname:s@" => { name => 'hostname' }, + "url-path:s@" => { name => 'url_path' }, + "port:s@" => { name => 'port' }, + "proto:s@" => { name => 'proto' }, + "username:s@" => { name => 'username' }, + "password:s@" => { name => 'password' }, + "timeout:s@" => { name => 'timeout' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; @@ -97,8 +93,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : ''; $self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : ''; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; - $self->{ssl} = (defined($self->{option_results}->{ssl})) ? shift(@{$self->{option_results}->{ssl}}) : 'tlsv1'; if (!defined($self->{hostname})) { $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); @@ -120,12 +114,10 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = $self->{proto}; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; $self->{option_results}->{credentials} = 1; $self->{option_results}->{basic} = 1; $self->{option_results}->{username} = $self->{username}; $self->{option_results}->{password} = $self->{password}; - $self->{option_results}->{ssl} = $self->{ssl}; $self->{option_results}->{warning_status} = ''; $self->{option_results}->{critical_status} = ''; } @@ -244,18 +236,10 @@ OnCommand API username. OnCommand API password. -=item B<--proxyurl> - -Proxy URL if any - =item B<--timeout> Set HTTP timeout -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =back =head1 DESCRIPTION diff --git a/storage/purestorage/restapi/custom/api.pm b/storage/purestorage/restapi/custom/api.pm index d9cf59023..5a478e0af 100644 --- a/storage/purestorage/restapi/custom/api.pm +++ b/storage/purestorage/restapi/custom/api.pm @@ -40,22 +40,19 @@ sub new { } if (!defined($options{noptions})) { - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "proxyurl:s" => { name => 'proxyurl' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, - "api-path:s" => { name => 'api_path' }, - }); + $options{options}->add_options(arguments => { + "hostname:s" => { name => 'hostname' }, + "username:s" => { name => 'username' }, + "password:s" => { name => 'password' }, + "timeout:s" => { name => 'timeout' }, + "api-path:s" => { name => 'api_path' }, + }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - $self->{http} = centreon::plugins::http->new(output => $self->{output}); + $self->{http} = centreon::plugins::http->new(%options); return $self; } @@ -89,7 +86,6 @@ sub check_options { $self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : undef; $self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; - $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef; $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/api/1.11'; if (!defined($self->{hostname})) { @@ -121,7 +117,6 @@ sub build_options_for_httplib { $self->{option_results}->{timeout} = $self->{timeout}; $self->{option_results}->{port} = 443; $self->{option_results}->{proto} = 'https'; - $self->{option_results}->{proxyurl} = $self->{proxyurl}; } sub settings { @@ -141,7 +136,7 @@ sub request_api { my $content = $self->{http}->request(method => $options{method}, url_path => $options{url_path}, query_form_post => $options{query_form_post}, critical_status => '', warning_status => '', unknown_status => ''); - my $response = $self->{http}->get_response(); + my $decoded; eval { $decoded = decode_json($content); @@ -151,7 +146,7 @@ sub request_api { $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); $self->{output}->option_exit(); } - if ($response->code() != 200) { + if ($self->{http}->get_code() != 200) { $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{msg}); $self->{output}->option_exit(); } @@ -197,8 +192,7 @@ sub get_session { $self->settings(); my $decoded = $self->request_api(method => 'POST', url_path => $self->{api_path} . '/auth/session', query_form_post => $encoded); - my $headers = $self->{http}->get_header(); - my $cookie = $headers->header('Set-Cookie'); + my ($cookie) = $self->{http}->get_header(name => 'Set-Cookie'); if (!defined($cookie)) { $self->{output}->add_option_msg(short_msg => "Cannot get session"); $self->{output}->option_exit(); @@ -262,18 +256,10 @@ Pure Storage username. Pure Storage password. -=item B<--proxyurl> - -Proxy URL if any. - =item B<--timeout> Set HTTP timeout in seconds (Default: '10'). -=item B<--ssl-opt> - -Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE"). - =item B<--api-path> API base url path (Default: '/api/1.11').