(plugin) storage::hp::p2000::xmlapi - mode health add fan and sas-link components (#3746)
This commit is contained in:
parent
06d63c76c8
commit
86f55e8ab0
|
@ -22,14 +22,7 @@ package storage::hp::p2000::xmlapi::mode::components::disk;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available',
|
||||
);
|
||||
use storage::hp::p2000::xmlapi::mode::components::resources qw($map_health);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -50,7 +43,7 @@ sub check {
|
|||
next if ($self->check_filter(section => 'disk', instance => $disk_id));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$disk_id}->{'health-numeric'}};
|
||||
my $state = $map_health->{$results->{$disk_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
|
|
|
@ -22,14 +22,7 @@ package storage::hp::p2000::xmlapi::mode::components::enclosure;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available',
|
||||
);
|
||||
use storage::hp::p2000::xmlapi::mode::components::resources qw($map_health);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -49,7 +42,7 @@ sub check {
|
|||
next if ($self->check_filter(section => 'enclosure', instance => $enc_id));
|
||||
$self->{components}->{enclosure}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$enc_id}->{'health-numeric'}};
|
||||
my $state = $map_health->{ $results->{$enc_id}->{'health-numeric'} };
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# Copyright 2022 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 storage::hp::p2000::xmlapi::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use storage::hp::p2000::xmlapi::mode::components::resources qw($map_health);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
$self->{components}->{fan} = { name => 'fan', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
my ($entries) = $self->{custom}->get_infos(
|
||||
cmd => 'show fans',
|
||||
base_type => 'fan',
|
||||
properties_name => '^health-numeric|location|durable-id|speed$',
|
||||
no_quit => 1
|
||||
);
|
||||
|
||||
my ($results, $duplicated) = ({}, {});
|
||||
foreach (@$entries) {
|
||||
my $name = $_->{location};
|
||||
$name = $_->{location} . ':' . $_->{'durable-id'} if (defined($duplicated->{$name}));
|
||||
if (defined($results->{$name})) {
|
||||
$duplicated->{$name} = 1;
|
||||
my $instance = $results->{$name}->{location} . ':' . $results->{$name}->{'durable-id'};
|
||||
$results->{$instance} = delete $results->{$name};
|
||||
$name = $_->{location} . ':' . $_->{'durable-id'};
|
||||
}
|
||||
$results->{$name} = $_;
|
||||
}
|
||||
|
||||
foreach my $instance (sort keys %$results) {
|
||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
my $state = $map_health->{ $results->{$instance}->{'health-numeric'} };
|
||||
my $speed = $results->{$instance}->{speed};
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fan '%s' status is %s [instance: %s, speed: %s]",
|
||||
$instance,
|
||||
$state,
|
||||
$instance,
|
||||
defined($speed) ? $speed : '-'
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fan', value => $state);
|
||||
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'", $instance, $state)
|
||||
);
|
||||
}
|
||||
|
||||
next if (!defined($speed));
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $speed);
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("Fan '%s' speed is %s rpm", $instance, $speed)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.fan.speed.rpm',
|
||||
unit => 'rpm',
|
||||
instances => $instance,
|
||||
value => $speed,
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -50,7 +50,7 @@ sub check {
|
|||
$results->{$name} = $_;
|
||||
}
|
||||
|
||||
foreach my $instance (sort keys %$results) {
|
||||
foreach my $instance (sort keys %$results) {
|
||||
next if ($self->check_filter(section => 'fru', instance => $instance));
|
||||
$self->{components}->{fru}->{total}++;
|
||||
|
||||
|
|
|
@ -22,14 +22,7 @@ package storage::hp::p2000::xmlapi::mode::components::psu;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'fault',
|
||||
3 => 'unknown',
|
||||
4 => 'not available'
|
||||
);
|
||||
use storage::hp::p2000::xmlapi::mode::components::resources qw($map_health);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -62,7 +55,7 @@ sub check {
|
|||
next if ($self->check_filter(section => 'psu', instance => $results->{$psu_id}->{'durable-id'}));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$psu_id}->{'health-numeric'}};
|
||||
my $state = $map_health->{ $results->{$psu_id}->{'health-numeric'} };
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
# Copyright 2022 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 storage::hp::p2000::xmlapi::mode::components::resources;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Exporter;
|
||||
|
||||
our $map_health;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw($map_health);
|
||||
|
||||
$map_health = {
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available'
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# Copyright 2022 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 storage::hp::p2000::xmlapi::mode::components::saslink;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use storage::hp::p2000::xmlapi::mode::components::resources qw($map_health);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking sas-links");
|
||||
$self->{components}->{saslink} = { name => 'saslink', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'saslink'));
|
||||
|
||||
my ($results) = $self->{custom}->get_infos(
|
||||
cmd => 'show sas-link-health',
|
||||
base_type => 'expander-ports',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric$',
|
||||
no_quit => 1
|
||||
);
|
||||
|
||||
foreach my $sas_id (keys %$results) {
|
||||
next if ($self->check_filter(section => 'saslink', instance => $sas_id));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
my $state = $map_health->{$results->{$sas_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"sas link '%s' status is %s [instance: %s]",
|
||||
$sas_id, $state, $sas_id
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'saslink', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Sas link '%s' status is '%s'", $sas_id, $state)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -111,8 +111,8 @@ sub check {
|
|||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'sensor', unit => $unit,
|
||||
nlabel => 'hardware.sensor.' . $type . (defined($units{$unit}->{long}) ? $units{$unit}->{long} : ''),
|
||||
unit => $unit,
|
||||
instances => $sensor_id,
|
||||
value => $value,
|
||||
warning => $warn,
|
||||
|
|
|
@ -22,14 +22,7 @@ package storage::hp::p2000::xmlapi::mode::components::vdisk;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available',
|
||||
);
|
||||
use storage::hp::p2000::xmlapi::mode::components::resources qw($map_health);
|
||||
|
||||
sub check_vdisk {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -38,7 +31,7 @@ sub check_vdisk {
|
|||
next if ($self->check_filter(section => 'vdisk', instance => $vdisk_id));
|
||||
$self->{components}->{vdisk}->{total}++;
|
||||
|
||||
my $state = $health{$options{results}->{$vdisk_id}->{'health-numeric'}};
|
||||
my $state = $map_health->{ $options{results}->{$vdisk_id}->{'health-numeric'} };
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
|
|
|
@ -29,17 +29,18 @@ sub set_system {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} =
|
||||
'^(?:sensor)$';
|
||||
'^(?:sensor|fan\.speed)$';
|
||||
|
||||
$self->{cb_hook1} = 'init_health';
|
||||
|
||||
$self->{thresholds} = {
|
||||
# disk, enclosure, vdisk
|
||||
# disk, enclosure, vdisk, saslink, fan
|
||||
default => [
|
||||
['ok', 'OK'],
|
||||
['degraded', 'WARNING'],
|
||||
['failed|fault', 'CRITICAL'],
|
||||
['unknown|not available', 'UNKNOWN']
|
||||
['unknown', 'UNKNOWN'],
|
||||
['not available', 'OK']
|
||||
],
|
||||
fru => [
|
||||
['ok', 'OK'],
|
||||
|
@ -57,7 +58,7 @@ sub set_system {
|
|||
|
||||
$self->{components_exec_load} = 0;
|
||||
$self->{components_path} = 'storage::hp::p2000::xmlapi::mode::components';
|
||||
$self->{components_module} = ['disk', 'enclosure', 'fru', 'psu', 'sensor', 'vdisk'];
|
||||
$self->{components_module} = ['disk', 'enclosure', 'fan', 'fru', 'psu', 'saslink', 'sensor', 'vdisk'];
|
||||
}
|
||||
|
||||
sub init_health {
|
||||
|
@ -68,11 +69,10 @@ sub init_health {
|
|||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ Check health status of storage.
|
|||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'disk', 'enclosure', 'fru', 'psu', 'sensor', 'vdisk'.
|
||||
Can be: 'disk', 'enclosure', 'fan', 'fru', 'psu', 'saslink', 'sensor', 'vdisk'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
|
@ -110,12 +110,12 @@ Example: --threshold-overload='disk,OK,unknown'
|
|||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'sensor' (syntax: type,instance,threshold)
|
||||
Set warning threshold for 'sensor', 'fan.speed' (syntax: type,instance,threshold)
|
||||
Example: --warning='sensor,temperature.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set warning threshold for 'sensors' (syntax: type,instance,threshold)
|
||||
Set warning threshold for 'sensor', 'fan.speed' (syntax: type,instance,threshold)
|
||||
Example: --warning='sensor,temperature.*,30'
|
||||
|
||||
=back
|
||||
|
|
Loading…
Reference in New Issue