enh(dell/idrac): hardware mode - add option --add-name-instance (#3200)

This commit is contained in:
qgarnier 2021-10-19 11:29:58 +02:00 committed by GitHub
parent 93ec810d77
commit 1dbc8aa362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 57 additions and 31 deletions

View File

@ -59,7 +59,7 @@ sub check {
my $instance = $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));
next if ($self->check_filter(section => 'amperage', instance => $instance, name => $result->{amperageProbeLocationName}));
$self->{components}->{amperage}->{total}++;
my ($divisor, $unit) = (1000, 'A');
@ -99,7 +99,12 @@ sub check {
next if ($result->{amperageProbeType} =~ /amperageProbeTypeIsDiscrete/);
if (defined($result->{amperageProbeReading}) && $result->{amperageProbeReading} =~ /[0-9]/) {
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'amperage', instance => $instance, value => $result->{amperageProbeReading});
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
section => 'amperage',
instance => $instance,
name => $result->{amperageProbeLocationName},
value => $result->{amperageProbeReading}
);
if ($checked == 0) {
$result->{amperageProbeLowerNonCriticalThreshold} = (defined($result->{amperageProbeLowerNonCriticalThreshold}) && $result->{amperageProbeLowerNonCriticalThreshold} =~ /[0-9]/) ?
$result->{amperageProbeLowerNonCriticalThreshold} / $divisor : '';

View File

@ -58,7 +58,7 @@ sub check {
my $instance = $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));
next if ($self->check_filter(section => 'coolingdevice', instance => $instance, name => $result->{coolingDeviceLocationName}));
$self->{components}->{coolingdevice}->{total}++;
$result->{coolingDeviceReading} = (defined($result->{coolingDeviceReading})) ? $result->{coolingDeviceReading} : 'unknown';
@ -72,8 +72,10 @@ sub check {
my $exit = $self->get_severity(label => 'default.state', section => 'coolingdevice.state', value => $result->{coolingDeviceStateSettings});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Cooling device '%s' state is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStateSettings}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Cooling device '%s' state is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStateSettings})
);
next;
}
@ -86,7 +88,12 @@ sub check {
}
if (defined($result->{coolingDeviceReading}) && $result->{coolingDeviceReading} =~ /[0-9]/) {
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'coolingdevice', instance => $instance, value => $result->{coolingDeviceReading});
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
section => 'coolingdevice',
instance => $instance,
name => $result->{coolingDeviceLocationName},
value => $result->{coolingDeviceReading}
);
if ($checked == 0) {
$result->{coolingDeviceLowerNonCriticalThreshold} = (defined($result->{coolingDeviceLowerNonCriticalThreshold}) && $result->{coolingDeviceLowerNonCriticalThreshold} =~ /[0-9]/) ?
$result->{coolingDeviceLowerNonCriticalThreshold} / 10 : '';

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingUnitTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'coolingunit', instance => $instance));
next if ($self->check_filter(section => 'coolingunit', instance => $instance, name => $result->{coolingUnitName}));
$self->{components}->{coolingunit}->{total}++;
$self->{output}->output_add(

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_enclosureTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'enclosure', instance => $instance));
next if ($self->check_filter(section => 'enclosure', instance => $instance, name => $result->{enclosureName}));
$self->{components}->{enclosure}->{total}++;
$self->{output}->output_add(

View File

@ -52,7 +52,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fruTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'fru', instance => $instance));
next if ($self->check_filter(section => 'fru', instance => $instance, name => $result->{fruSerialNumberName}));
$self->{components}->{fru}->{total}++;
$self->{output}->output_add(

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_memoryDeviceTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'memory', instance => $instance));
next if ($self->check_filter(section => 'memory', instance => $instance, name => $result->{memoryDeviceLocationName}));
$self->{components}->{memory}->{total}++;
$self->{output}->output_add(

View File

@ -52,7 +52,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_networkDeviceTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'network', instance => $instance));
next if ($self->check_filter(section => 'network', instance => $instance, name => $result->{networkDeviceProductName}));
$self->{components}->{network}->{total}++;
$self->{output}->output_add(

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_pCIDeviceTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'pci', instance => $instance));
next if ($self->check_filter(section => 'pci', instance => $instance, name => $result->{pCIDeviceDescriptionName}));
$self->{components}->{pci}->{total}++;
$self->{output}->output_add(

View File

@ -64,7 +64,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
next if ($self->check_filter(section => 'pdisk', instance => $instance));
next if ($self->check_filter(section => 'pdisk', instance => $instance, name => $result->{physicalDiskFQDD}));
$self->{components}->{pdisk}->{total}++;
if ($result->{physicalDiskState} eq 'ready') {

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($self->check_filter(section => 'processor', instance => $instance));
next if ($self->check_filter(section => 'processor', instance => $instance, name => $result->{processorDeviceFQDD}));
$self->{components}->{processor}->{total}++;
$self->{output}->output_add(

View File

@ -52,13 +52,13 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerSupplyTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{powerSupplyLocationName}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s' status is '%s' [instance = %s]",
$result->{powerSupplyLocationName}, $result->{powerSupplyStatus}, $instance,
$result->{powerSupplyLocationName}, $result->{powerSupplyStatus}, $instance
)
);

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerUnitTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'punit', instance => $instance));
next if ($self->check_filter(section => 'punit', instance => $instance, name => $result->{powerUnitName}));
$self->{components}->{punit}->{total}++;
$self->{output}->output_add(

View File

@ -52,13 +52,13 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemSlotTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'slot', instance => $instance));
next if ($self->check_filter(section => 'slot', instance => $instance, name => $result->{systemSlotSlotExternalSlotName}));
$self->{components}->{slot}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"slot '%s' status is '%s' [instance = %s]",
$result->{systemSlotSlotExternalSlotName}, $result->{systemSlotStatus}, $instance,
$result->{systemSlotSlotExternalSlotName}, $result->{systemSlotStatus}, $instance
)
);

View File

@ -48,13 +48,13 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($self->check_filter(section => 'storagebattery', instance => $instance));
next if ($self->check_filter(section => 'storagebattery', instance => $instance, name => $result->{batteryFQDD}));
$self->{components}->{storagebattery}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"storage battery '%s' status is '%s' [instance = %s]",
$result->{batteryFQDD}, $result->{batteryComponentStatus}, $instance,
$result->{batteryFQDD}, $result->{batteryComponentStatus}, $instance
)
);

View File

@ -48,13 +48,13 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($self->check_filter(section => 'storagectrl', instance => $instance));
next if ($self->check_filter(section => 'storagectrl', instance => $instance, name => $result->{controllerFQDD}));
$self->{components}->{storagectrl}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"storage controller '%s' status is '%s' [instance = %s]",
$result->{controllerFQDD}, $result->{controllerComponentStatus}, $instance,
$result->{controllerFQDD}, $result->{controllerComponentStatus}, $instance
)
);

View File

@ -53,7 +53,7 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemBatteryTableEntry}, instance => $instance);
next if ($self->check_filter(section => 'systembattery', instance => $instance));
next if ($self->check_filter(section => 'systembattery', instance => $instance, name => $result->{systemBatteryLocationName}));
$self->{components}->{systembattery}->{total}++;
$self->{output}->output_add(

View File

@ -66,7 +66,7 @@ sub check {
my $instance = $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));
next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{temperatureProbeLocationName}));
$self->{components}->{temperature}->{total}++;
$result->{temperatureProbeReading} = (defined($result->{temperatureProbeReading})) ? $result->{temperatureProbeReading} / 10 : 'unknown';
@ -98,9 +98,14 @@ sub check {
)
);
}
if (defined($result->{temperatureProbeReading}) && $result->{temperatureProbeReading} =~ /[0-9]/) {
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureProbeReading});
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
section => 'temperature',
instance => $instance,
name => $result->{temperatureProbeLocationName},
value => $result->{temperatureProbeReading}
);
if ($checked == 0) {
$result->{temperatureProbeLowerNonCriticalThreshold} = (defined($result->{temperatureProbeLowerNonCriticalThreshold}) && $result->{temperatureProbeLowerNonCriticalThreshold} =~ /[0-9]/) ?
$result->{temperatureProbeLowerNonCriticalThreshold} / 10 : '';

View File

@ -48,13 +48,13 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($self->check_filter(section => 'vdisk', instance => $instance));
next if ($self->check_filter(section => 'vdisk', instance => $instance, name => $result->{virtualDiskFQDD}));
$self->{components}->{vdisk}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"virtual disk '%s' state is '%s' [instance = %s]",
$result->{virtualDiskFQDD}, $result->{virtualDiskState}, $instance,
$result->{virtualDiskFQDD}, $result->{virtualDiskState}, $instance
)
);

View File

@ -58,7 +58,7 @@ sub check {
my $instance = $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));
next if ($self->check_filter(section => 'voltage', instance => $instance, name => $result->{voltageProbeLocationName}));
$self->{components}->{voltage}->{total}++;
$result->{voltageProbeReading} = (defined($result->{voltageProbeReading})) ? $result->{voltageProbeReading} / 1000 : 'unknown';
@ -92,7 +92,12 @@ sub check {
}
if (defined($result->{voltageProbeReading}) && $result->{voltageProbeReading} =~ /[0-9]/) {
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltageProbeReading});
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
section => 'voltage',
instance => $instance,
name => $result->{voltageProbeLocationName},
value => $result->{voltageProbeReading}
);
if ($checked == 0) {
$result->{voltageProbeLowerNonCriticalThreshold} = (defined($result->{voltageProbeLowerNonCriticalThreshold}) && $result->{voltageProbeLowerNonCriticalThreshold} =~ /[0-9]/) ?
$result->{voltageProbeLowerNonCriticalThreshold} / 1000 : '';

View File

@ -141,6 +141,10 @@ Can be: 'amperage', 'coolingdevice', 'coolingunit', 'enclosure',
Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=psu)
Can also exclude specific instance: --filter=temperature,1.1
=item B<--add-name-instance>
Add literal description for instance value (used in filter and threshold options).
=item B<--no-component>
Return an error if no compenents are checked.