Add curl backend http

This commit is contained in:
garnier-quentin 2019-03-06 16:47:46 +01:00
parent afe74917f9
commit 782fa22f56
89 changed files with 1865 additions and 2261 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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
=cut

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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
=cut

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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} = \&centreon::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<http>.
=cut

View File

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

View File

@ -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<http>.
=cut

View File

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

View File

@ -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<http>.
=cut

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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').

View File

@ -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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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).

View File

@ -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<custom>.
=cut
=cut

View File

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

View File

@ -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').

View File

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

View File

@ -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').