+ Fix #10 : add ilo plugin

This commit is contained in:
garnier-quentin 2016-11-04 14:55:54 +01:00
parent 6a1f1791fc
commit d4664329b0
15 changed files with 1411 additions and 0 deletions

View File

@ -0,0 +1,337 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::custom::api;
use strict;
use warnings;
use IO::Socket::SSL;
use LWP::UserAgent;
use XML::Simple;
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}
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_help(package => __PACKAGE__, sections => 'XML API OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{mode} = $options{mode};
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {
my ($self, %options) = @_;
foreach (keys %{$options{default}}) {
if ($_ eq $self->{mode}) {
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
if (!defined($self->{option_results}->{$opt}[$i])) {
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
}
}
}
}
}
}
sub check_options {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to set hostname option.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{username}) || $self->{option_results}->{username} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to set username option.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{password})) {
$self->{output}->add_option_msg(short_msg => "Need to set password option.");
$self->{output}->option_exit();
}
$self->{ssl_opts} = '';
if (!defined($self->{option_results}->{ssl_opt})) {
$self->{ssl_opts} = 'SSL_verify_mode => SSL_VERIFY_NONE';
} else {
foreach (keys %{$self->{option_results}->{ssl_opt}}) {
$self->{ssl_opts} .= "$_ => " . $self->{option_results}->{ssl_opt}->{$_} . ", ";
}
}
return 0;
}
sub find_ilo_version {
my ($self, %options) = @_;
($self->{ilo2}, $self->{ilo3}) = (0, 0);
my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port},
eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout});
if (!$client) {
$self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR");
$self->{output}->option_exit();
}
print $client 'POST /ribcl HTTP/1.1' . "\r\n";
print $client "HOST: me" . "\r\n"; # Mandatory for http 1.1
print $client "User-Agent: locfg-Perl-script/3.0\r\n";
print $client "Content-length: 30" . "\r\n"; # Mandatory for http 1.1
print $client 'Connection: Close' . "\r\n"; # Required
print $client "\r\n"; # End of http header
print $client "<RIBCL VERSION=\"2.0\"></RIBCL>\r\n"; # Used by Content-length
my $ln = <$client>;
if ($ln =~ m/HTTP.1.1 200 OK/) {
$self->{ilo3} = 1;
} else {
$self->{ilo2} = 1;
}
close $client;
}
sub get_ilo2_data {
my ($self, %options) = @_;
my $client = new IO::Socket::SSL->new(PeerAddr => $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port},
eval $self->{ssl_opts}, Timeout => $self->{option_results}->{timeout});
if (!$client) {
$self->{output}->add_option_msg(short_msg => "Failed to establish SSL connection: $!, ssl_error=$SSL_ERROR");
$self->{output}->option_exit();
}
print $client '<?xml version="1.0"?>' . "\r\n";
print $client '<RIBCL VERSION="2.21">' . "\r\n";
print $client '<LOGIN USER_LOGIN="' . $self->{option_results}->{username} . '" PASSWORD="' . $self->{option_results}->{password} . '">' . "\r\n";
print $client '<SERVER_INFO MODE="read">' . "\r\n";
print $client '<GET_EMBEDDED_HEALTH />' . "\r\n";
print $client '</SERVER_INFO>' . "\r\n";
print $client '</LOGIN>' . "\r\n";
print $client '</RIBCL>' . "\r\n";
while (my $line = <$client>) {
$self->{content} .= $line;
}
close $client;
}
sub get_ilo3_data {
my ($self, %options) = @_;
my $xml_script = "<RIBCL VERSION=\"2.21\">
<LOGIN USER_LOGIN=\"$self->{option_results}->{username}\" PASSWORD=\"$self->{option_results}->{password}\">
<SERVER_INFO MODE=\"read\">
<GET_EMBEDDED_HEALTH />
</SERVER_INFO>
</LOGIN>
</RIBCL>
";
my $ua = LWP::UserAgent->new(keep_alive => 0, protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout});
my $req = HTTP::Request->new(POST => "https://" . $self->{option_results}->{hostname} . '/ribcl');
$req->content_length(length($xml_script));
$req->content($xml_script);
$req->header(TE => 'chunked');
$req->header(Connection => 'Close');
my $context = new IO::Socket::SSL::SSL_Context(eval $self->{ssl_opts});
IO::Socket::SSL::set_default_context($context);
my $response = $ua->request($req);
$self->{content} = $response->content;
if (!$response->is_success) {
$self->{output}->add_option_msg(short_msg => "Cannot get data: $response->status_line");
$self->{output}->option_exit();
}
}
sub check_ilo_error {
my ($self, %options) = @_;
# Looking for:
# <RESPONSE
# STATUS="0x005F"
# MESSAGE='Login credentials rejected.'
# />
while ($self->{content} =~ /<response[^>]*?status="0x(.*?)"[^>]*?message='(.*?)'/msig) {
my ($status_code, $message) = ($1, $2);
if ($status_code !~ /^0+$/) {
$self->{output}->add_option_msg(short_msg => "Cannot get data: $2");
$self->{output}->option_exit();
}
}
}
sub change_shitty_xml {
my ($self, %options) = @_;
# Can be like that the root <RIBCL VERSION="2.22" /> ???!!
$options{response} =~ s/<RIBCL VERSION="(.*?)"\s*\/>/<RIBCL VERSION="$1">/mg;
# ILO2 can send:
# <DRIVES>
# <Backplane firmware version="Unknown", enclosure addr="224"/>
# <Drive Bay: "1"; status: "Ok"; uid led: "Off">
# <Drive Bay: "2"; status: "Ok"; uid led: "Off">
# <Drive Bay: "3"; status: "Not Installed"; uid led: "Off">
# <Drive Bay: "4"; status: "Not Installed"; uid led: "Off">
# <Backplane firmware version="1.16own", enclosure addr="226"/>
# <Drive Bay: "5"; status: "Not Installed"; uid led: "Off">
# <Drive Bay: "6"; status: "Not Installed"; uid led: "Off">
# <Drive Bay: "7"; status: "Not Installed"; uid led: "Off">
# <Drive Bay: "8"; status: "Not Installed"; uid led: "Off">
# </DRIVES>
$options{response} =~ s/<Backplane firmware version="(.*?)", enclosure addr="(.*?)"/<BACKPLANE FIRMWARE_VERSION="$1" ENCLOSURE_ADDR="$2"/mg;
$options{response} =~ s/<Drive Bay: "(.*?)"; status: "(.*?)"; uid led: "(.*?)">/<DRIVE_BAY NUM="$1" STATUS="$2" UID_LED="$3" \/>/mg;
return $options{response};
}
sub get_ilo_response {
my ($self, %options) = @_;
# ilo result is so shitty. We get the good result from size...
my ($length, $response) = (0, '');
foreach (split /<\?xml.*?\?>/, $self->{content}) {
if (length($_) > $length) {
$response = $_;
$length = length($_);
}
}
$response = $self->change_shitty_xml(response => $response);
my $xml_result;
eval {
$xml_result = XMLin($response,
ForceArray => ['FAN', 'TEMP', 'MODULE', 'SUPPLY', 'PROCESSOR', 'NIC',
'SMART_STORAGE_BATTERY', 'CONTROLLER', 'DRIVE_ENCLOSURE',
'LOGICAL_DRIVE', 'PHYSICAL_DRIVE', 'DRIVE_BAY']);
};
if ($@) {
$self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@");
$self->{output}->option_exit();
}
return $xml_result;
}
sub get_ilo_data {
my ($self, %options) = @_;
$self->{content} = '';
if (!defined($self->{option_results}->{force_ilo3})) {
$self->find_ilo_version();
} else {
$self->{ilo3} = 1;
}
if ($self->{ilo3} == 1) {
$self->get_ilo3_data();
} else {
$self->get_ilo2_data();
}
$self->{content} =~ s/\r//sg;
$self->{output}->output_add(long_msg => $self->{content}, debug => 1);
$self->check_ilo_error();
return $self->get_ilo_response();
}
1;
__END__
=head1 NAME
ILO API
=head1 SYNOPSIS
ilo api
=head1 XML API OPTIONS
=over 8
=item B<--hostname>
Hostname to query.
=item B<--username>
ILO username.
=item B<--password>
ILO password.
=item B<--port>
ILO Port (Default: 443).
=item B<--timeout>
Set timeout (Default: 30).
=item B<--force-ilo3>
Don't try to find ILO version.
=item B<--ssl-opt>
Set SSL Options (--ssl-opt="SSL_version=SSLv3").
Default: --ssl-opt="SSL_version=SSL_VERIFY_NONE"
=back
=head1 DESCRIPTION
B<custom>.
=cut

View File

@ -0,0 +1,68 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::battery;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking batteries");
$self->{components}->{battery} = {name => 'battery', total => 0, skip => 0};
return if ($self->check_filter(section => 'battery'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{POWER_SUPPLIES}->{SMART_STORAGE_BATTERY}));
#<POWER_SUPPLIES>
# <SMART_STORAGE_BATTERY>
# <LABEL VALUE = "Battery 1"/>
# <PRESENT VALUE = "Yes"/>
# <STATUS VALUE = "OK"/>
# <MODEL VALUE = "727258-B21"/>
# <SPARE VALUE = "815983-001"/>
# <SERIAL_NUMBER VALUE = "6EZBN0FB230885"/>
# <CAPACITY VALUE = "96 Watts"/>
# <FIRMWARE_VERSION VALUE = "1.1"/>
# </SMART_STORAGE_BATTERY>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{POWER_SUPPLIES}->{SMART_STORAGE_BATTERY}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'battery', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'battery', instance => $instance));
$self->{components}->{battery}->{total}++;
$self->{output}->output_add(long_msg => sprintf("battery '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'battery', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Battery '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
1;

View File

@ -0,0 +1,68 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::cpu;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cpu");
$self->{components}->{cpu} = {name => 'cpu', total => 0, skip => 0};
return if ($self->check_filter(section => 'cpu'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{PROCESSORS}->{PROCESSOR}));
#<PROCESSORS>
# <PROCESSOR>
# <LABEL VALUE = "Proc 1"/>
# <NAME VALUE = " Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz "/>
# <STATUS VALUE = "OK"/>
# <SPEED VALUE = "2500 MHz"/>
# <EXECUTION_TECHNOLOGY VALUE = "10/10 cores; 20 threads"/>
# <MEMORY_TECHNOLOGY VALUE = "64-bit Capable"/>
# <INTERNAL_L1_CACHE VALUE = "320 KB"/>
# <INTERNAL_L2_CACHE VALUE = "2560 KB"/>
# <INTERNAL_L3_CACHE VALUE = "25600 KB"/>
# </PROCESSOR>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{PROCESSORS}->{PROCESSOR}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'cpu', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'cpu', instance => $instance));
$self->{components}->{cpu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cpu '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'CPU', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
1;

View File

@ -0,0 +1,68 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::ctrl;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking controllers");
$self->{components}->{ctrl} = {name => 'ctrl', total => 0, skip => 0};
return if ($self->check_filter(section => 'ctrl'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}));
#<STORAGE>
# <CONTROLLER>
# <LABEL VALUE = "Controller on System Board"/>
# <STATUS VALUE = "OK"/>
# <CONTROLLER_STATUS VALUE = "OK"/>
# <SERIAL_NUMBER VALUE = "001438031632F40"/>
# <MODEL VALUE = "HP Smart Array P420i Controller"/>
# <FW_VERSION VALUE = "5.42"/>
# <CACHE_MODULE_STATUS VALUE = "OK"/>
# <CACHE_MODULE_SERIAL_NUM VALUE = "PBKUC0BRH6V822"/>
# <CACHE_MODULE_MEMORY VALUE = "1048576 KB"/>
#
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'ctrl', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'ctrl', instance => $instance));
$self->{components}->{ctrl}->{total}++;
$self->{output}->output_add(long_msg => sprintf("controller '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'ctrl', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Controller '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
1;

View File

@ -0,0 +1,69 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::driveencl;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking drive enclosures");
$self->{components}->{driveencl} = {name => 'driveencl', total => 0, skip => 0};
return if ($self->check_filter(section => 'driveencl'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}));
#<STORAGE>
# <CONTROLLER>
# ...
# <DRIVE_ENCLOSURE>
# <LABEL VALUE = "Port 1I Box 1"/>
# <STATUS VALUE = "OK"/>
# <DRIVE_BAY VALUE = "04"/>
# </DRIVE_ENCLOSURE>
#
foreach my $ctrl (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}}) {
next if (!defined($ctrl->{DRIVE_ENCLOSURE}));
foreach my $result (@{$ctrl->{DRIVE_ENCLOSURE}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'driveencl', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'driveencl', instance => $instance));
$self->{components}->{driveencl}->{total}++;
$self->{output}->output_add(long_msg => sprintf("drive enclosure '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'driveencl', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Drive enclosure '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
}
1;

View File

@ -0,0 +1,83 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::fan;
use strict;
use warnings;
my %map_speed_unit = (
'percentage' => '%',
);
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'fan'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{FANS}->{FAN}));
# <FANS>
# <FAN>
# <LABEL VALUE = "Fan Block 1"/>
# <ZONE VALUE = "System"/>
# <STATUS VALUE = "Ok"/>
# <SPEED VALUE = "35" UNIT="Percentage"/>
# </FAN>
#
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{FANS}->{FAN}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'fan', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s] [value = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance,
$result->{SPEED}->{VALUE}));
my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
next if ($result->{SPEED}->{VALUE} !~ /[0-9]/);
my $unit = $map_speed_unit{lc($result->{SPEED}->{UNIT})};
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{SPEED}->{VALUE});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Fan '%s' is %s %s", $result->{LABEL}->{VALUE}, $result->{SPEED}->{VALUE}, $unit));
}
$self->{output}->perfdata_add(label => 'fan_' . $instance, unit => $unit,
value => $result->{SPEED}->{VALUE},
warning => $warn,
critical => $crit,
min => 0
);
}
}
1;

View File

@ -0,0 +1,72 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::ldrive;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking logical drives");
$self->{components}->{ldrive} = {name => 'ldrive', total => 0, skip => 0};
return if ($self->check_filter(section => 'ldrive'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}));
#<STORAGE>
# <CONTROLLER>
# ...
# <LOGICAL_DRIVE>
# <LABEL VALUE = "01"/>
# <STATUS VALUE = "OK"/>
# <CAPACITY VALUE = "419 GB"/>
# <FAULT_TOLERANCE VALUE = "RAID 1/RAID 1+0"/>
# <ENCRYPTION_STATUS VALUE = "Not Encrypted"/>
#
#
foreach my $ctrl (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}}) {
next if (!defined($ctrl->{LOGICAL_DRIVE}));
foreach my $result (@{$ctrl->{LOGICAL_DRIVE}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'ldrive', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'ldrive', instance => $instance));
$self->{components}->{ldrive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("logical drive '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'ldrive', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Logical drive '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
}
1;

View File

@ -0,0 +1,74 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::memory;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking memories");
$self->{components}->{memory} = {name => 'memory', total => 0, skip => 0};
return if ($self->check_filter(section => 'memory'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{MEMORY}->{MEMORY_DETAILS}));
#<MEMORY>
# <MEMORY_DETAILS>
# <CPU_1>
# <SOCKET VALUE = "1"/>
# <STATUS VALUE = "Good, In Use"/>
# <HP_SMART_MEMORY VALUE = "Yes"/>
# <PART NUMBER = "712383-081"/>
# <TYPE VALUE = "DIMM DDR3"/>
# <SIZE VALUE = "16384 MB"/>
# <FREQUENCY VALUE = "1866 MHz"/>
# <MINIMUM_VOLTAGE VALUE = "1.50 v"/>
# <RANKS VALUE = "2"/>
# <TECHNOLOGY VALUE = "RDIMM"/>
# </CPU_1>
foreach my $cpu_name (sort keys %{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{MEMORY}->{MEMORY_DETAILS}}) {
$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{MEMORY}->{MEMORY_DETAILS}->{$cpu_name} = [$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{MEMORY}->{MEMORY_DETAILS}->{$cpu_name}]
if (ref($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{MEMORY}->{MEMORY_DETAILS}->{$cpu_name}) ne 'ARRAY');
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{MEMORY}->{MEMORY_DETAILS}->{$cpu_name}}) {
my $instance = lc($cpu_name) . '.' . $result->{SOCKET}->{VALUE};
next if ($self->check_filter(section => 'memory', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'memory', instance => $instance));
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(long_msg => sprintf("memory '%s' status is '%s' [instance = %s]",
$instance, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'memory', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Memory '%s' status is '%s'", $instance, $result->{STATUS}->{VALUE}));
}
}
}
}
1;

View File

@ -0,0 +1,65 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::nic;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking nic");
$self->{components}->{nic} = {name => 'nic', total => 0, skip => 0};
return if ($self->check_filter(section => 'nic'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{NIC_INFORMATION}->{NIC}));
#<NIC_INFORMATION>
# <NIC>
# <NETWORK_PORT VALUE = "Port 1"/>
# <PORT_DESCRIPTION VALUE = "HP Ethernet 1Gb 4-port 331FLR Adapter #4"/>
# <LOCATION VALUE = "Embedded"/>
# <MAC_ADDRESS VALUE = "a0:d3:c1:f3:47:c3"/>
# <IP_ADDRESS VALUE = "N/A"/>
# <STATUS VALUE = "OK"/>
# </NIC>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{NIC_INFORMATION}->{NIC}}) {
my $instance = $result->{NETWORK_PORT}->{VALUE};
next if ($self->check_filter(section => 'nic', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'nic', instance => $instance));
$self->{components}->{nic}->{total}++;
$self->{output}->output_add(long_msg => sprintf("nic '%s' status is '%s' [instance = %s]",
$instance, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(section => 'nic', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("NIC '%s' status is '%s'", $instance, $result->{STATUS}->{VALUE}));
}
}
}
1;

View File

@ -0,0 +1,117 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::pdrive;
use strict;
use warnings;
sub load { }
sub check_ilo4 {
my ($self) = @_;
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}));
#<STORAGE>
# <CONTROLLER>
# ...
# <LOGICAL_DRIVE>
# <PHYSICAL_DRIVE>
# <LABEL VALUE = "Port 1I Box 1 Bay 1"/>
# <STATUS VALUE = "OK"/>
# <SERIAL_NUMBER VALUE = "KHG25T5R"/>
# <MODEL VALUE = "EG0450FBVFM"/>
# <CAPACITY VALUE = "419 GB"/>
# <LOCATION VALUE = "Port 1I Box 1 Bay 1"/>
# <FW_VERSION VALUE = "HPD9"/>
# <DRIVE_CONFIGURATION VALUE = "Configured"/>
# <ENCRYPTION_STATUS VALUE = "Not Encrypted"/>
#
foreach my $ctrl (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{STORAGE}->{CONTROLLER}}) {
next if (!defined($ctrl->{LOGICAL_DRIVE}));
foreach my $ldrive (@{$ctrl->{LOGICAL_DRIVE}}) {
next if (!defined($ldrive->{PHYSICAL_DRIVE}));
foreach my $result (@{$ldrive->{PHYSICAL_DRIVE}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'pdrive', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'pdrive', instance => $instance));
$self->{components}->{pdrive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'pdrive', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical drive '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
}
}
sub check_ilo2 {
my ($self) = @_;
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{DRIVES}->{DRIVE_BAY}));
# In ILO2:
# <DRIVES>
# <BACKPLANE FIRMWARE_VERSION="1.16" ENCLOSURE_ADDR="224"/>
# <DRIVE_BAY NUM="1" STATUS="Ok" UID_LED="Off" />
# <DRIVE_BAY NUM="2" STATUS="Ok" UID_LED="Off" />
# <DRIVE_BAY NUM="3" STATUS="Not Installed" UID_LED="Off" />
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{DRIVES}->{DRIVE_BAY}}) {
my $instance = $result->{NUM};
next if ($self->check_filter(section => 'pdrive', instance => $instance));
next if ($result->{STATUS} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'pdrive', instance => $instance));
$self->{components}->{pdrive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is '%s' [instance = %s]",
$result->{NUM}, $result->{STATUS}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'pdrive', value => $result->{STATUS});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical drive '%s' status is '%s'", $result->{NUM}, $result->{STATUS}));
}
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking physical drives");
$self->{components}->{pdrive} = {name => 'pdrive', total => 0, skip => 0};
return if ($self->check_filter(section => 'pdrive'));
check_ilo4($self);
check_ilo2($self);
}
1;

View File

@ -0,0 +1,69 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::psu;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psu', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{POWER_SUPPLIES}->{SUPPLY}));
#<POWER_SUPPLIES>
# <SUPPLY>
# <LABEL VALUE = "Power Supply 1"/>
# <PRESENT VALUE = "Yes"/>
# <STATUS VALUE = "Good, In Use"/>
# <PDS VALUE = "Yes"/>
# <HOTPLUG_CAPABLE VALUE = "Yes"/>
# <MODEL VALUE = "656362-B21"/>
# <SPARE VALUE = "660184-001"/>
# <SERIAL_NUMBER VALUE = "5BXRA0D4D6M0FW"/>
# <CAPACITY VALUE = "460 Watts"/>
# <FIRMWARE_VERSION VALUE = "1.00"/>
# </SUPPLY>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{POWER_SUPPLIES}->{SUPPLY}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
1;

View File

@ -0,0 +1,83 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::temperature;
use strict;
use warnings;
my %map_unit = (
'celsius' => 'C',
);
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{TEMPERATURE}->{TEMP}));
#<TEMPERATURE>
# <TEMP>
# <LABEL VALUE = "Temp 1"/>
# <LOCATION VALUE = "Ambient"/>
# <STATUS VALUE = "Ok"/>
# <CURRENTREADING VALUE = "20" UNIT="Celsius"/>
# <CAUTION VALUE = "42" UNIT="Celsius"/>
# <CRITICAL VALUE = "46" UNIT="Celsius"/>
# </TEMP>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{TEMPERATURE}->{TEMP}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'temperature', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [location = %s] [value = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance, $result->{LOCATION}->{VALUE},
$result->{CURRENTREADING}->{VALUE}));
my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
next if ($result->{CURRENTREADING}->{VALUE} !~ /[0-9]/);
my $unit = $map_unit{lc($result->{CURRENTREADING}->{UNIT})};
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{CURRENTREADING}->{VALUE});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Temperature '%s' is %s %s", $result->{LABEL}->{VALUE}, $result->{CURRENTREADING}->{VALUE}, $unit));
}
$self->{output}->perfdata_add(label => 'temp_' . $instance, unit => $unit,
value => $result->{CURRENTREADING}->{VALUE},
warning => $warn,
critical => $crit,
);
}
}
1;

View File

@ -0,0 +1,61 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::components::vrm;
use strict;
use warnings;
sub load { }
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking vrm");
$self->{components}->{vrm} = {name => 'vrm', total => 0, skip => 0};
return if ($self->check_filter(section => 'vrm'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{VRM}->{MODULE}));
#<VRM>
# <MODULE>
# <LABEL VALUE = "VRM 1"/>
# <STATUS VALUE = "Ok"/>
# </MODULE>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{VRM}->{MODULE}}) {
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'vrm', instance => $instance));
next if ($result->{STATUS}->{VALUE} =~ /not installed|n\/a|not present|not applicable/i &&
$self->absent_problem(section => 'vrm', instance => $instance));
$self->{components}->{vrm}->{total}++;
$self->{output}->output_add(long_msg => sprintf("vrm '%s' status is '%s' [instance = %s]",
$result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'vrm', value => $result->{STATUS}->{VALUE});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("VRM '%s' status is '%s'", $result->{LABEL}->{VALUE}, $result->{STATUS}->{VALUE}));
}
}
}
1;

View File

@ -0,0 +1,128 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} =
'^(temperature|fan|vrm|psu|cpu|memory|nic|battery|ctrl|driveencl|pdrive|ldrive)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$';
$self->{cb_hook2} = 'api_execute';
$self->{thresholds} = {
default => [
['Ok', 'OK'],
['Good', 'OK'],
['Not installed', 'OK'],
['Not Present', 'OK'],
['NOT APPLICABLE', 'OK'],
['n/a', 'OK'],
['Unknown', 'UNKNOWN'],
['.*', 'CRITICAL'],
],
nic => [
['Ok', 'OK'],
['Unknown', 'OK'],
['.*', 'CRITICAL'],
],
};
$self->{components_path} = 'hardware::server::hp::ilo::xmlapi::mode::components';
$self->{components_module} = ['fan', 'temperature', 'vrm', 'psu', 'cpu', 'memory', 'nic', 'battery', 'ctrl',
'driveencl', 'pdrive', 'ldrive'];
}
sub api_execute {
my ($self, %options) = @_;
$self->{xml_result} = $options{custom}->get_ilo_data();
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'fan', 'temperature', 'vrm', 'psu', 'cpu', 'memory', 'nic', 'battery', 'ctrl',
'driveencl', 'pdrive', 'ldrive'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=fan)
Can also exclude specific instance: --filter="fan,Fan Block 1"
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping)
Can be specific or global: --absent-problem="fan,Fan Block 1"
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='fan,OK,degraded'
=item B<--warning>
Set warning threshold for 'temperature', 'fan' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for 'temperature', 'fan' (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,50'
=back
=cut

View File

@ -0,0 +1,49 @@
#
# Copyright 2016 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 hardware::server::hp::ilo::xmlapi::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'hardware::server::hp::ilo::xmlapi::mode::hardware',
);
$self->{custom_modes}{api} = 'hardware::server::hp::ilo::xmlapi::custom::api';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check HP ILO (ilo 2/3/4) with XML API.
=cut