enh(idrac/snmp): mode hardware - add health component (#3430)

This commit is contained in:
qgarnier 2022-01-27 10:26:11 +01:00 committed by GitHub
parent 33368c9f0a
commit 0944755a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 163 additions and 41 deletions

View File

@ -55,8 +55,9 @@ sub check {
return if ($self->check_filter(section => 'amperage'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_amperageProbeTableEntry}})) {
next if ($oid !~ /^$mapping->{amperageProbeStatus}->{oid}\.(.*)$/);
my $instance = $1;
next if ($oid !~ /^$mapping->{amperageProbeStatus}->{oid}\.(\d+)\.(\d+)$/);
my $instance = $1 . '.' . $2;
my $chassis_name = $self->get_chassis_name(id => $1);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_amperageProbeTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'amperage', instance => $instance, name => $result->{amperageProbeLocationName}));
@ -72,7 +73,7 @@ sub check {
$result->{amperageProbeReading} = (defined($result->{amperageProbeReading})) ? $result->{amperageProbeReading} / $divisor : 'unknown';
$self->{output}->output_add(
long_msg => sprintf(
"amperage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]",
"amperage '%s' status is '%s' [instance: %s] [state: %s] [value: %s]",
$result->{amperageProbeLocationName}, $result->{amperageProbeStatus}, $instance,
$result->{amperageProbeStateSettings}, $result->{amperageProbeReading}
)
@ -137,9 +138,9 @@ sub check {
);
}
$self->{output}->perfdata_add(
label => 'amperage', unit => $unit,
nlabel => 'hardware.probe.amperage.' . ($unit eq 'A' ? 'ampere' : 'watt'),
instances => $result->{amperageProbeLocationName},
unit => $unit,
instances => [$chassis_name, $result->{amperageProbeLocationName}],
value => $result->{amperageProbeReading},
warning => $warn,
critical => $crit

View File

@ -54,17 +54,18 @@ sub check {
return if ($self->check_filter(section => 'coolingdevice'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingDeviceTableEntry}})) {
next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(.*)$/);
my $instance = $1;
next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(\d+)\.(\d+)$/);
my $instance = $1 . '.' . $2;
my $chassis_name = $self->get_chassis_name(id => $1);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingDeviceTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'coolingdevice', instance => $instance, name => $result->{coolingDeviceLocationName}));
$self->{components}->{coolingdevice}->{total}++;
$result->{coolingDeviceReading} = (defined($result->{coolingDeviceReading})) ? $result->{coolingDeviceReading} : 'unknown';
$self->{output}->output_add(
long_msg => sprintf(
"cooling device '%s' status is '%s' [instance = %s] [state = %s] [value = %s]",
"cooling device '%s' status is '%s' [instance: %s] [state: %s] [value: %s]",
$result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus}, $instance,
$result->{coolingDeviceStateSettings}, $result->{coolingDeviceReading}
)
@ -126,12 +127,12 @@ sub check {
);
}
$self->{output}->perfdata_add(
label => 'fan', unit => 'rpm',
nlabel => 'hardware.fan.speed.rpm',
instances => $result->{coolingDeviceLocationName},
unit => 'rpm',
instances => [$chassis_name, $result->{coolingDeviceLocationName}],
value => $result->{coolingDeviceReading},
warning => $warn,
critical => $crit,
critical => $crit
);
}
}

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"cooling unit '%s' status is '%s' [instance = %s] [state = %s]",
"cooling unit '%s' status is '%s' [instance: %s] [state: %s]",
$result->{coolingUnitName}, $result->{coolingUnitStatus}, $instance,
$result->{coolingUnitStateSettings}
)

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"enclosure '%s' status is '%s' [instance = %s] [state = %s]",
"enclosure '%s' status is '%s' [instance: %s] [state: %s]",
$result->{enclosureName}, $result->{enclosureRollUpStatus}, $instance,
$result->{enclosureState}
)

View File

@ -57,7 +57,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"fru '%s' status is '%s' [instance = %s]",
"fru '%s' status is '%s' [instance: %s]",
$result->{fruSerialNumberName}, $result->{fruInformationStatus}, $instance,
)
);

View File

@ -0,0 +1,93 @@
#
# 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 hardware::server::dell::idrac::snmp::mode::components::health;
use strict;
use warnings;
use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status);
my $mapping_health = {
psuComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.9', map => \%map_status, label => 'psuAll' }, # systemStatePowerSupplyStatusCombined
voltageComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.12', map => \%map_status, label => 'voltageAll' }, # systemStateVoltageStatusCombined
amperageComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.15', map => \%map_status, label => 'amperageAll' }, # systemStateAmperageStatusCombined
coolingDevComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.21', map => \%map_status, label => 'coolingDeviceAll' }, # systemStateCoolingDeviceStatusCombined
tempComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.24', map => \%map_status, label => 'temperatureAll' }, # systemStateTemperatureStatusCombined
memoryComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.27', map => \%map_status, label => 'memoryAll' }, # systemStateMemoryDeviceStatusCombined
intrusionComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.30', map => \%map_status, label => 'intrusionAll' }, # systemStateChassisIntrusionStatusCombined
powerComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.42', map => \%map_status, label => 'powerUnitAll' }, # systemStatePowerUnitStatusCombined
coolingUnitComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.44', map => \%map_status, label => 'coolingUnitAll' }, # systemStateCoolingUnitStatusCombined
processorComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.50', map => \%map_status, label => 'processorAll' }, # systemStateProcessorDeviceStatusCombined
batteryComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.52', map => \%map_status, label => 'batteryAll' }, # systemStateBatteryStatusCombined
sdCardUnitComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.54', map => \%map_status, label => 'sdCardUnitAll' }, # systemStateSDCardUnitStatusCombined
sdCardDevComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.56', map => \%map_status, label => 'sdCardDeviceAll' }, # systemStateSDCardDeviceStatusCombined
idsmCardDevComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.60', map => \%map_status, label => 'idsmCardDeviceAll' } # systemStateIDSDMCardDeviceStatusCombined
};
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking health");
$self->{components}->{health} = { name => 'health', total => 0, skip => 0 };
return if ($self->check_filter(section => 'health'));
my $instances = $self->get_chassis_instances();
return if (scalar(@$instances) <= 0);
$self->{snmp}->load(
oids => [map($_->{oid}, values(%$mapping_health))],
instances => $instances
);
my $results = $self->{snmp}->get_leef();
foreach my $instance (@$instances) {
my $result = $self->{snmp}->map_instance(mapping => $mapping_health, results => $results, instance => $instance);
my $chassis_name = $self->get_chassis_name(id => $instance);
foreach (keys %$mapping_health) {
next if (!defined($result->{$_}));
my $name = $chassis_name . ':' . $mapping_health->{$_}->{label};
next if ($self->check_filter(section => 'health', instance => $instance));
$self->{components}->{health}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"health '%s' status is %s [instance: %s]",
$name,
$result->{$_},
$instance
)
);
my $exit = $self->get_severity(label => 'default.status', section => 'health', value => $result->{$_});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Health '%s' status is %s", $name, $result->{$_})
);
}
}
}
}
1;

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"memory '%s' status is '%s' [instance = %s] [state = %s]",
"memory '%s' status is '%s' [instance: %s] [state: %s]",
$result->{memoryDeviceLocationName}, $result->{memoryDeviceStatus}, $instance,
$result->{memoryDeviceStateSettings}
)

View File

@ -57,7 +57,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"network '%s' status is '%s' [instance = %s]",
"network '%s' status is '%s' [instance: %s]",
$result->{networkDeviceProductName}, $result->{networkDeviceStatus}, $instance
)
);

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"pci '%s' status is '%s' [instance = %s] [state = %s]",
"pci '%s' status is '%s' [instance: %s] [state: %s]",
$result->{pCIDeviceDescriptionName}, $result->{pCIDeviceStatus}, $instance,
$result->{pCIDeviceStateSettings}
)

View File

@ -73,7 +73,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"physical disk '%s' status is '%s' [instance = %s] [state = %s] [smart alert = %s]",
"physical disk '%s' status is '%s' [instance: %s] [state: %s] [smart alert: %s]",
$result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}, $instance,
$result->{physicalDiskState}, $result->{physicalDiskSmartAlertIndication}
)

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"processor '%s' status is '%s' [instance = %s] [state = %s]",
"processor '%s' status is '%s' [instance: %s] [state: %s]",
$result->{processorDeviceFQDD}, $result->{processorDeviceStatus}, $instance,
$result->{processorDeviceStateSettings}
)

View File

@ -57,7 +57,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is '%s' [instance = %s]",
"power supply '%s' status is '%s' [instance: %s]",
$result->{powerSupplyLocationName}, $result->{powerSupplyStatus}, $instance
)
);

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"power unit '%s' status is '%s' [instance = %s] [state = %s]",
"power unit '%s' status is '%s' [instance: %s] [state: %s]",
$result->{powerUnitName}, $result->{powerUnitStatus}, $instance,
$result->{powerUnitStateSettings}
)

View File

@ -57,7 +57,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"slot '%s' status is '%s' [instance = %s]",
"slot '%s' status is '%s' [instance: %s]",
$result->{systemSlotSlotExternalSlotName}, $result->{systemSlotStatus}, $instance
)
);

View File

@ -53,7 +53,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"storage battery '%s' status is '%s' [instance = %s]",
"storage battery '%s' status is '%s' [instance: %s]",
$result->{batteryFQDD}, $result->{batteryComponentStatus}, $instance
)
);

View File

@ -53,7 +53,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"storage controller '%s' status is '%s' [instance = %s]",
"storage controller '%s' status is '%s' [instance: %s]",
$result->{controllerFQDD}, $result->{controllerComponentStatus}, $instance
)
);

View File

@ -58,7 +58,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"system battery '%s' status is '%s' [instance = %s] [state = %s]",
"system battery '%s' status is '%s' [instance: %s] [state: %s]",
$result->{systemBatteryLocationName},
$result->{systemBatteryStatus}, $instance,
$result->{systemBatteryStateSettings}

View File

@ -62,8 +62,9 @@ sub check {
return if ($self->check_filter(section => 'temperature'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureProbeTableEntry}})) {
next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(.*)$/);
my $instance = $1;
next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(\d+)\.(\d+)$/);
my $instance = $1 . '.' . $2;
my $chassis_name = $self->get_chassis_name(id => $1);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureProbeTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{temperatureProbeLocationName}));
@ -72,7 +73,7 @@ sub check {
$result->{temperatureProbeReading} = (defined($result->{temperatureProbeReading})) ? $result->{temperatureProbeReading} / 10 : 'unknown';
$self->{output}->output_add(
long_msg => sprintf(
"temperature '%s' status is '%s' [instance = %s] [state = %s] [value = %s]",
"temperature '%s' status is '%s' [instance: %s] [state: %s] [value: %s]",
$result->{temperatureProbeLocationName}, $result->{temperatureProbeStatus}, $instance,
$result->{temperatureProbeStateSettings}, $result->{temperatureProbeReading}
)
@ -140,9 +141,9 @@ sub check {
);
}
$self->{output}->perfdata_add(
label => 'temp', unit => 'C',
nlabel => 'hardware.probe.temperature.celsius',
instances => $result->{temperatureProbeLocationName},
unit => 'C',
instances => [$chassis_name, $result->{temperatureProbeLocationName}],
value => $result->{temperatureProbeReading},
warning => $warn,
critical => $crit

View File

@ -53,7 +53,7 @@ sub check {
$self->{output}->output_add(
long_msg => sprintf(
"virtual disk '%s' state is '%s' [instance = %s]",
"virtual disk '%s' state is '%s' [instance: %s]",
$result->{virtualDiskFQDD}, $result->{virtualDiskState}, $instance
)
);

View File

@ -54,8 +54,9 @@ sub check {
return if ($self->check_filter(section => 'voltage'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_voltageProbeTableEntry}})) {
next if ($oid !~ /^$mapping->{voltageProbeStatus}->{oid}\.(.*)$/);
my $instance = $1;
next if ($oid !~ /^$mapping->{voltageProbeStatus}->{oid}\.(\d+)\.(\d+)$/);
my $instance = $1 . '.' . $2;
my $chassis_name = $self->get_chassis_name(id => $1);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_voltageProbeTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance, name => $result->{voltageProbeLocationName}));
@ -64,7 +65,7 @@ sub check {
$result->{voltageProbeReading} = (defined($result->{voltageProbeReading})) ? $result->{voltageProbeReading} / 1000 : 'unknown';
$self->{output}->output_add(
long_msg => sprintf(
"voltage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]",
"voltage '%s' status is '%s' [instance: %s] [state: %s] [value: %s]",
$result->{voltageProbeLocationName}, $result->{voltageProbeStatus}, $instance,
$result->{voltageProbeStateSettings}, $result->{voltageProbeReading}
)
@ -132,9 +133,9 @@ sub check {
);
}
$self->{output}->perfdata_add(
label => 'voltage', unit => 'V',
nlabel => 'hardware.probe.voltage.volt',
instances => $result->{voltageProbeLocationName},
unit => 'V',
instances => [$chassis_name, $result->{voltageProbeLocationName}],
value => $result->{voltageProbeReading},
warning => $warn,
critical => $crit

View File

@ -94,23 +94,49 @@ sub set_system {
$self->{components_path} = 'hardware::server::dell::idrac::snmp::mode::components';
$self->{components_module} = [
'amperage', 'coolingdevice', 'coolingunit', 'enclosure',
'amperage', 'coolingdevice', 'coolingunit', 'enclosure', 'health',
'fru', 'memory', 'network', 'pci', 'pdisk',
'processor', 'psu', 'punit', 'slot', 'storagebattery',
'storagectrl', 'systembattery', 'temperature', 'voltage', 'vdisk'
];
}
my $oid_chassisName = '.1.3.6.1.4.1.674.10892.5.4.300.10.1.7';
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
push @{$self->{request}}, { oid => $oid_chassisName };
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub get_chassis_name {
my ($self, %options) = @_;
my $name = 'unknown';
if (defined($self->{results}->{$oid_chassisName}->{ $oid_chassisName . '.' . $options{id} })) {
$name = $self->{results}->{$oid_chassisName}->{ $oid_chassisName . '.' . $options{id} }
}
return $name;
}
sub get_chassis_instances {
my ($self, %options) = @_;
my $instances = [];
foreach (keys %{$self->{results}->{$oid_chassisName}}) {
/\.(\d+)$/;
push @$instances, $1;
}
return $instances;
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});
@ -132,7 +158,7 @@ Check hardware components.
Which component to check (Default: '.*').
Can be: 'amperage', 'coolingdevice', 'coolingunit', 'enclosure',
'fru', 'memory', 'network', 'pci', 'pdisk',
'health', 'fru', 'memory', 'network', 'pci', 'pdisk',
'processor', 'psu', 'punit', 'slot', 'storagebattery',
'storagectrl', 'systembattery', 'temperature', 'voltage', 'vdisk'.
@ -169,4 +195,3 @@ Example: --critical='temperature,.*,40'
=back
=cut