add url-path option for iplabel newtest (#2562)
This commit is contained in:
parent
8b46c7f4e4
commit
378ab147e8
|
@ -47,6 +47,7 @@ sub new {
|
||||||
'port:s' => { name => 'port' },
|
'port:s' => { name => 'port' },
|
||||||
'proto:s' => { name => 'proto' },
|
'proto:s' => { name => 'proto' },
|
||||||
'timeout:s' => { name => 'timeout' },
|
'timeout:s' => { name => 'timeout' },
|
||||||
|
'url-path:s' => { name => 'url_path' },
|
||||||
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
||||||
'warning-http-status:s' => { name => 'warning_http_status' },
|
'warning-http-status:s' => { name => 'warning_http_status' },
|
||||||
'critical-http-status:s' => { name => 'critical_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->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
$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->{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->{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_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} : '';
|
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : '';
|
||||||
|
@ -132,7 +134,7 @@ sub request_api {
|
||||||
$self->settings();
|
$self->settings();
|
||||||
|
|
||||||
my $content = $self->{http}->request(
|
my $content = $self->{http}->request(
|
||||||
url_path => $options{endpoint},
|
url_path => $self->{url_path} . $options{endpoint},
|
||||||
unknown_status => $self->{unknown_http_status},
|
unknown_status => $self->{unknown_http_status},
|
||||||
warning_status => $self->{warning_http_status},
|
warning_status => $self->{warning_http_status},
|
||||||
critical_status => $self->{critical_http_status}
|
critical_status => $self->{critical_http_status}
|
||||||
|
@ -181,6 +183,10 @@ Port used (Default: 8085)
|
||||||
|
|
||||||
Specify https if needed (Default: 'http')
|
Specify https if needed (Default: 'http')
|
||||||
|
|
||||||
|
=item B<--url-path>
|
||||||
|
|
||||||
|
API url path (Default: '/rest')
|
||||||
|
|
||||||
=item B<--api-username>
|
=item B<--api-username>
|
||||||
|
|
||||||
API username.
|
API username.
|
||||||
|
|
|
@ -55,7 +55,7 @@ sub check_options {
|
||||||
sub discovery_robots {
|
sub discovery_robots {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $robots = $options{custom}->request_api(endpoint => '/rest/api/robots');
|
my $robots = $options{custom}->request_api(endpoint => '/api/robots');
|
||||||
|
|
||||||
my $nodes = {};
|
my $nodes = {};
|
||||||
foreach my $robot (@$robots) {
|
foreach my $robot (@$robots) {
|
||||||
|
@ -84,7 +84,7 @@ sub discovery_robots {
|
||||||
sub discovery_scenarios {
|
sub discovery_scenarios {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $scenarios = $options{custom}->request_api(endpoint => '/rest/api/measures');
|
my $scenarios = $options{custom}->request_api(endpoint => '/api/measures');
|
||||||
|
|
||||||
my $nodes = {};
|
my $nodes = {};
|
||||||
foreach my $scenario (@$scenarios) {
|
foreach my $scenario (@$scenarios) {
|
||||||
|
@ -113,7 +113,7 @@ sub run {
|
||||||
my $disco_stats;
|
my $disco_stats;
|
||||||
$disco_stats->{start_time} = time();
|
$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 = [];
|
my $results = [];
|
||||||
if ($self->{option_results}->{resource_type} eq 'robot') {
|
if ($self->{option_results}->{resource_type} eq 'robot') {
|
||||||
|
|
|
@ -44,7 +44,7 @@ sub check_options {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return $options{custom}->request_api(endpoint => '/rest/api/instances');
|
return $options{custom}->request_api(endpoint => '/api/instances');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
|
|
@ -136,7 +136,7 @@ sub manage_selection {
|
||||||
$last_timestamp = time() - (60 * 5);
|
$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} = {};
|
$self->{robots} = {};
|
||||||
my $scenarios_last_exec = {};
|
my $scenarios_last_exec = {};
|
||||||
my $query_filter = [];
|
my $query_filter = [];
|
||||||
|
@ -186,7 +186,7 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
my $results = [];
|
my $results = [];
|
||||||
if ($query_filter_num > 0) {
|
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 = {
|
my $mapping_status = {
|
||||||
|
|
Loading…
Reference in New Issue