mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-26 07:05:06 +02:00
(plugin) hardware::server::hp::ilo::xmlapi - add option --force-ilo2 option (#3527)
This commit is contained in:
parent
b0b7838cd8
commit
4fd85b4eae
@ -47,7 +47,8 @@ sub new {
|
|||||||
'port:s' => { name => 'port', default => 443 },
|
'port:s' => { name => 'port', default => 443 },
|
||||||
'username:s' => { name => 'username' },
|
'username:s' => { name => 'username' },
|
||||||
'password:s' => { name => 'password' },
|
'password:s' => { name => 'password' },
|
||||||
'force-ilo3' => { name => 'force_ilo3' }
|
'force-ilo3' => { name => 'force_ilo3' },
|
||||||
|
'force-ilo2' => { name => 'force_ilo2' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$options{options}->add_help(package => __PACKAGE__, sections => 'XML API OPTIONS', once => 1);
|
$options{options}->add_help(package => __PACKAGE__, sections => 'XML API OPTIONS', once => 1);
|
||||||
@ -55,6 +56,9 @@ sub new {
|
|||||||
$self->{output} = $options{output};
|
$self->{output} = $options{output};
|
||||||
$self->{http} = centreon::plugins::http->new(%options);
|
$self->{http} = centreon::plugins::http->new(%options);
|
||||||
|
|
||||||
|
$self->{ilo2} = 0;
|
||||||
|
$self->{ilo3} = 0;
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,9 +106,10 @@ sub check_options {
|
|||||||
sub find_ilo_version {
|
sub find_ilo_version {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
($self->{ilo2}, $self->{ilo3}) = (0, 0);
|
my $client = new IO::Socket::SSL->new(
|
||||||
my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port},
|
PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port},
|
||||||
eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout});
|
eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout}
|
||||||
|
);
|
||||||
if (!$client) {
|
if (!$client) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR");
|
$self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -129,8 +134,10 @@ sub find_ilo_version {
|
|||||||
sub get_ilo2_data {
|
sub get_ilo2_data {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port},
|
my $client = new IO::Socket::SSL->new(
|
||||||
eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout});
|
PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port},
|
||||||
|
eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout}
|
||||||
|
);
|
||||||
if (!$client) {
|
if (!$client) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR");
|
$self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
@ -274,10 +281,14 @@ sub get_ilo_response {
|
|||||||
$response = $self->change_shitty_xml(response => $response);
|
$response = $self->change_shitty_xml(response => $response);
|
||||||
my $xml_result;
|
my $xml_result;
|
||||||
eval {
|
eval {
|
||||||
$xml_result = XMLin($response,
|
$xml_result = XMLin(
|
||||||
ForceArray => ['FAN', 'TEMP', 'MODULE', 'SUPPLY', 'PROCESSOR', 'NIC',
|
$response,
|
||||||
|
ForceArray => [
|
||||||
|
'FAN', 'TEMP', 'MODULE', 'SUPPLY', 'PROCESSOR', 'NIC',
|
||||||
'SMART_STORAGE_BATTERY', 'CONTROLLER', 'DRIVE_ENCLOSURE',
|
'SMART_STORAGE_BATTERY', 'CONTROLLER', 'DRIVE_ENCLOSURE',
|
||||||
'LOGICAL_DRIVE', 'PHYSICAL_DRIVE', 'DRIVE_BAY', 'BACKPLANE']);
|
'LOGICAL_DRIVE', 'PHYSICAL_DRIVE', 'DRIVE_BAY', 'BACKPLANE'
|
||||||
|
]
|
||||||
|
);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@");
|
$self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@");
|
||||||
@ -292,10 +303,11 @@ sub get_ilo_data {
|
|||||||
|
|
||||||
$self->{content} = '';
|
$self->{content} = '';
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{force_ilo3})) {
|
if (!defined($self->{option_results}->{force_ilo3}) && !defined($self->{option_results}->{force_ilo2})) {
|
||||||
$self->find_ilo_version();
|
$self->find_ilo_version();
|
||||||
} else {
|
} else {
|
||||||
$self->{ilo3} = 1;
|
$self->{ilo3} = 1 if (defined($self->{option_results}->{force_ilo3}));
|
||||||
|
$self->{ilo2} = 1 if (defined($self->{option_results}->{force_ilo2}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($self->{ilo3} == 1) {
|
if ($self->{ilo3} == 1) {
|
||||||
@ -349,7 +361,11 @@ Set timeout (Default: 30).
|
|||||||
|
|
||||||
=item B<--force-ilo3>
|
=item B<--force-ilo3>
|
||||||
|
|
||||||
Don't try to find ILO version.
|
No version identification. Directly check for version 3.
|
||||||
|
|
||||||
|
=item B<--force-ilo2>
|
||||||
|
|
||||||
|
No version identification. Directly check for version 2.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user