add url-path option for iplabel newtest (#2562)

This commit is contained in:
qgarnier 2021-02-01 15:55:38 +01:00 committed by GitHub
parent 082917bc82
commit 3722a5e3f2
4 changed files with 13 additions and 7 deletions

View File

@ -47,6 +47,7 @@ sub new {
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'timeout:s' => { name => 'timeout' },
'url-path:s' => { name => 'url_path' },
'unknown-http-status:s' => { name => 'unknown_http_status' },
'warning-http-status:s' => { name => 'warning_http_status' },
'critical-http-status:s' => { name => 'critical_http_status' }
@ -74,6 +75,7 @@ sub check_options {
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/rest';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : '';
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : '';
@ -132,7 +134,7 @@ sub request_api {
$self->settings();
my $content = $self->{http}->request(
url_path => $options{endpoint},
url_path => $self->{url_path} . $options{endpoint},
unknown_status => $self->{unknown_http_status},
warning_status => $self->{warning_http_status},
critical_status => $self->{critical_http_status}
@ -181,6 +183,10 @@ Port used (Default: 8085)
Specify https if needed (Default: 'http')
=item B<--url-path>
API url path (Default: '/rest')
=item B<--api-username>
API username.

View File

@ -55,7 +55,7 @@ sub check_options {
sub discovery_robots {
my ($self, %options) = @_;
my $robots = $options{custom}->request_api(endpoint => '/rest/api/robots');
my $robots = $options{custom}->request_api(endpoint => '/api/robots');
my $nodes = {};
foreach my $robot (@$robots) {
@ -84,7 +84,7 @@ sub discovery_robots {
sub discovery_scenarios {
my ($self, %options) = @_;
my $scenarios = $options{custom}->request_api(endpoint => '/rest/api/measures');
my $scenarios = $options{custom}->request_api(endpoint => '/api/measures');
my $nodes = {};
foreach my $scenario (@$scenarios) {
@ -113,7 +113,7 @@ sub run {
my $disco_stats;
$disco_stats->{start_time} = time();
my $instances = $options{custom}->request_api(endpoint => '/rest/api/instances');
my $instances = $options{custom}->request_api(endpoint => '/api/instances');
my $results = [];
if ($self->{option_results}->{resource_type} eq 'robot') {

View File

@ -44,7 +44,7 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
return $options{custom}->request_api(endpoint => '/rest/api/instances');
return $options{custom}->request_api(endpoint => '/api/instances');
}
sub run {

View File

@ -136,7 +136,7 @@ sub manage_selection {
$last_timestamp = time() - (60 * 5);
}
my $instances = $options{custom}->request_api(endpoint => '/rest/api/instances');
my $instances = $options{custom}->request_api(endpoint => '/api/instances');
$self->{robots} = {};
my $scenarios_last_exec = {};
my $query_filter = [];
@ -186,7 +186,7 @@ sub manage_selection {
}
my $results = [];
if ($query_filter_num > 0) {
$results = $options{custom}->request_api(endpoint => '/rest/api/results?range=' . $timespan . $query_filter_string);
$results = $options{custom}->request_api(endpoint => '/api/results?range=' . $timespan . $query_filter_string);
}
my $mapping_status = {