mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 16:45:04 +02:00
(plugin) hardware::server::dell::vxm::restapi - add --api-version option (#4177)
This commit is contained in:
parent
59e8e2422a
commit
f3e876f9d5
@ -43,6 +43,7 @@ sub new {
|
|||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'api-username:s' => { name => 'api_username' },
|
'api-username:s' => { name => 'api_username' },
|
||||||
'api-password:s' => { name => 'api_password' },
|
'api-password:s' => { name => 'api_password' },
|
||||||
|
'api-version:s' => { name => 'api_version' },
|
||||||
'hostname:s' => { name => 'hostname' },
|
'hostname:s' => { name => 'hostname' },
|
||||||
'port:s' => { name => 'port' },
|
'port:s' => { name => 'port' },
|
||||||
'proto:s' => { name => 'proto' },
|
'proto:s' => { name => 'proto' },
|
||||||
@ -77,6 +78,7 @@ sub check_options {
|
|||||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 50;
|
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 50;
|
||||||
$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} : '';
|
||||||
|
$self->{api_version} = defined($self->{option_results}->{api_version}) && $self->{option_results}->{api_version} ne '' ? $self->{option_results}->{api_version} : '2';
|
||||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
||||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||||
@ -138,7 +140,7 @@ sub request {
|
|||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $content = $self->{http}->request(
|
my $content = $self->{http}->request(
|
||||||
url_path => $options{endpoint},
|
url_path => '/rest/vxm/v' . $self->{api_version} . $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}
|
||||||
@ -195,6 +197,10 @@ API username.
|
|||||||
|
|
||||||
API password.
|
API password.
|
||||||
|
|
||||||
|
=item B<--api-version>
|
||||||
|
|
||||||
|
API version (Default: 2).
|
||||||
|
|
||||||
=item B<--timeout>
|
=item B<--timeout>
|
||||||
|
|
||||||
Set timeout in seconds (Default: 50).
|
Set timeout in seconds (Default: 50).
|
||||||
|
@ -128,7 +128,7 @@ sub new {
|
|||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $results = $options{custom}->request(endpoint => '/rest/vxm/v1/chassis');
|
my $results = $options{custom}->request(endpoint => '/chassis');
|
||||||
|
|
||||||
$self->{global} = { num_chassis => 0, unhealthy => 0 };
|
$self->{global} = { num_chassis => 0, unhealthy => 0 };
|
||||||
$self->{chassis} = {};
|
$self->{chassis} = {};
|
||||||
|
@ -55,7 +55,7 @@ sub check_options {
|
|||||||
sub discovery_host {
|
sub discovery_host {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $hosts = $options{custom}->request(endpoint => '/rest/vxm/v1/hosts');
|
my $hosts = $options{custom}->request(endpoint => '/hosts');
|
||||||
|
|
||||||
my $disco_data = [];
|
my $disco_data = [];
|
||||||
foreach my $host (@$hosts) {
|
foreach my $host (@$hosts) {
|
||||||
|
@ -165,7 +165,7 @@ sub new {
|
|||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $results = $options{custom}->request(endpoint => '/rest/vxm/v1/hosts');
|
my $results = $options{custom}->request(endpoint => '/hosts');
|
||||||
|
|
||||||
$self->{global} = { num_hosts => 0, unhealthy => 0 };
|
$self->{global} = { num_hosts => 0, unhealthy => 0 };
|
||||||
$self->{hosts} = {};
|
$self->{hosts} = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user