enh(dell/cmc/snmp): add disk and vdisk components (#3010)

This commit is contained in:
qgarnier 2021-08-03 11:05:28 +02:00 committed by GitHub
parent 0715c44d5c
commit 4fafc965e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 296 additions and 60 deletions

View File

@ -26,19 +26,19 @@ use warnings;
# In MIB 'DELL-RAC-MIB'
my $mapping = {
drsWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.13', section => 'power', label => 'power', unit => 'watt' },
drsAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.14', section => 'current', label => 'current', unit => 'ampere' },
drsAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.14', section => 'current', label => 'current', unit => 'ampere' }
};
my $oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry = '.1.3.6.1.4.1.674.10892.2.4.1.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking chassis");
$self->{components}->{chassis} = { name => 'chassis', total => 0, skip => 0 };
return if ($self->check_filter(section => 'chassis'));
@ -51,17 +51,29 @@ sub check {
next if ($self->check_filter(section => 'chassis', instance => $instance));
$self->{components}->{chassis}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Chassis '%s': power %s W, current %s A [instance: %s].",
$instance, $result->{drsWattsReading}, $result->{drsAmpsReading},
$instance
));
$self->{output}->output_add(
long_msg => sprintf(
"chassis '%s': power %s W, current %s A [instance: %s].",
$instance,
$result->{drsWattsReading},
$result->{drsAmpsReading},
$instance
)
);
foreach my $probe (('drsWattsReading', 'drsAmpsReading')) {
next if (!defined($result->{$probe}));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassis.' . $mapping->{$probe}->{section}, instance => $instance, value => $result->{$probe});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Chassis '%s' %s is %s%s", $instance,
$mapping->{$probe}->{section}, $result->{$probe}, $mapping->{$probe}->{unit}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Chassis '%s' %s is %s%s",
$instance,
$mapping->{$probe}->{section},
$result->{$probe},
$mapping->{$probe}->{unit}
)
);
}
$self->{output}->perfdata_add(
label => 'chassis_' . $mapping->{$probe}->{label}, unit => $mapping->{$probe}->{unit},

View File

@ -0,0 +1,76 @@
#
# Copyright 2021 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::cmc::snmp::mode::components::disk;
use strict;
use warnings;
use hardware::server::dell::cmc::snmp::mode::components::resources qw($map_status);
my $mapping = {
name => { oid => '.1.3.6.1.4.1.674.10892.2.6.1.20.130.4.1.2' }, # physicalDiskName
status => { oid => '.1.3.6.1.4.1.674.10892.2.6.1.20.130.4.1.24', map => $map_status } # physicalDiskComponentStatus
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{name}->{oid} }, { oid => $mapping->{status}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking disks");
$self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 };
return if ($self->check_filter(section => 'disk'));
my $snmp_result = {
%{$self->{results}->{ $mapping->{name}->{oid} }},
%{$self->{results}->{ $mapping->{status}->{oid} }}
};
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
next if ($oid !~ /^$mapping->{name}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"disk '%s' status is '%s' [instance: %s]",
$result->{name},
$result->{status},
$instance
)
);
my $exit = $self->get_severity(label => 'default', section => 'disk', value => $result->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("disk '%s' status is '%s'", $result->{name}, $result->{status})
);
}
}
}
1;

View File

@ -22,32 +22,24 @@ package hardware::server::dell::cmc::snmp::mode::components::health;
use strict;
use warnings;
my %map_health_status = (
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable',
);
use hardware::server::dell::cmc::snmp::mode::components::resources qw($map_status);
# In MIB 'DELL-RAC-MIB'
my $mapping = {
drsIOMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.2', map => \%map_health_status, descr => 'IOM status' },
drsKVMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.3', map => \%map_health_status, descr => 'iKVM status' },
drsRedCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.4', map => \%map_health_status, descr => 'Redundancy status' },
drsPowerCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.5', map => \%map_health_status, descr => 'Power status' },
drsFanCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.6', map => \%map_health_status, descr => 'Fan status' },
drsBladeCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.7', map => \%map_health_status, descr => 'Blade status' },
drsTempCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.8', map => \%map_health_status, descr => 'Temperature status' },
drsCMCCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.9', map => \%map_health_status, descr => 'CMC status' },
drsIOMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.2', map => $map_status, descr => 'IOM status' },
drsKVMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.3', map => $map_status, descr => 'iKVM status' },
drsRedCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.4', map => $map_status, descr => 'Redundancy status' },
drsPowerCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.5', map => $map_status, descr => 'Power status' },
drsFanCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.6', map => $map_status, descr => 'Fan status' },
drsBladeCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.7', map => $map_status, descr => 'Blade status' },
drsTempCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.8', map => $map_status, descr => 'Temperature status' },
drsCMCCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.9', map => $map_status, descr => 'CMC status' }
};
my $oid_drsStatusNowGroup = '.1.3.6.1.4.1.674.10892.2.3.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_drsStatusNowGroup, start => $mapping->{drsIOMCurrStatus}->{oid}, end => $mapping->{drsCMCCurrStatus}->{oid} };
}
@ -58,7 +50,7 @@ sub check {
$self->{components}->{health} = {name => 'health', total => 0, skip => 0};
return if ($self->check_filter(section => 'health'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_drsStatusNowGroup}, instance => '0');
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_drsStatusNowGroup}, instance => 0);
foreach my $probe (keys %{$mapping}) {
next if (!defined($result->{$probe}));
$mapping->{$probe}->{oid} =~ /\.(\d+)$/;
@ -67,15 +59,24 @@ sub check {
next if ($self->check_filter(section => 'health', instance => $instance));
$self->{components}->{health}->{total}++;
$self->{output}->output_add(long_msg => sprintf("%s is %s [instance: %s].",
$mapping->{$probe}->{descr}, $result->{$probe},
$instance
));
my $exit = $self->get_severity(section => 'health', value => $result->{$probe});
$self->{output}->output_add(
long_msg => sprintf(
"%s is %s [instance: %s].",
$mapping->{$probe}->{descr},
$result->{$probe},
$instance
)
);
my $exit = $self->get_severity(label => 'default', section => 'health', value => $result->{$probe});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s is %s",
$mapping->{$probe}->{descr}, $result->{$probe}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"%s is %s",
$mapping->{$probe}->{descr},
$result->{$probe}
)
);
}
}
}

View File

@ -26,7 +26,7 @@ use warnings;
my %map_psu_capable = (
1 => 'absent',
2 => 'none',
3 => 'basic',
3 => 'basic'
);
# In MIB 'DELL-RAC-MIB'
@ -35,7 +35,7 @@ my $mapping = {
drsPSUMonitoringCapable => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.4', map => \%map_psu_capable },
drsPSUVoltsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.5', section => 'voltage', label => 'voltage', unit => 'volt' },
drsPSUAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.6', section => 'current', label => 'current', unit => 'ampere' },
drsPSUWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.7', section => 'power', label => 'power', unit => 'watt' },
drsPSUWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.2.1.7', section => 'power', label => 'power', unit => 'watt' }
};
my $oid_drsCMCPSUTableEntry = '.1.3.6.1.4.1.674.10892.2.4.2.1';
@ -61,17 +61,29 @@ sub check {
next if ($result->{drsPSUMonitoringCapable} !~ /basic/i);
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s': power %s W, current %s A, voltage %s V [instance: %s].",
$result->{drsPSULocation}, $result->{drsPSUWattsReading}, $result->{drsPSUAmpsReading}, $result->{drsPSUVoltsReading},
$instance
));
$self->{output}->output_add(
long_msg => sprintf(
"power supply '%s': power %s W, current %s A, voltage %s V [instance: %s].",
$result->{drsPSULocation},
$result->{drsPSUWattsReading},
$result->{drsPSUAmpsReading},
$result->{drsPSUVoltsReading},
$instance
)
);
foreach my $probe (('drsPSUVoltsReading', 'drsPSUAmpsReading', 'drsPSUWattsReading')) {
next if (!defined($result->{$probe}));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu.' . $mapping->{$probe}->{section}, instance => $instance, value => $result->{$probe});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' %s is %s%s", $result->{drsPSULocation},
$mapping->{$probe}->{section}, $result->{$probe}, $mapping->{$probe}->{unit}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Power supply '%s' %s is %s%s",
$result->{drsPSULocation},
$mapping->{$probe}->{section},
$result->{$probe}, $mapping->{$probe}->{unit}
)
);
}
$self->{output}->perfdata_add(
label => 'psu_' . $mapping->{$probe}->{label}, unit => $mapping->{$probe}->{unit},

View File

@ -0,0 +1,41 @@
#
# Copyright 2021 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::cmc::snmp::mode::components::resources;
use strict;
use warnings;
use Exporter;
our $map_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($map_status);
$map_status = {
1 => 'other',
2 => 'unknown',
3 => 'ok',
4 => 'nonCritical',
5 => 'critical',
6 => 'nonRecoverable'
};
1;

View File

@ -27,7 +27,7 @@ use warnings;
my $mapping = {
drsChassisFrontPanelAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.10', instance => 'chassis', descr => 'Chassis Ambient temperature' },
drsCMCAmbientTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.11', instance => 'ambient', descr => 'CMC Ambient temperarture' },
drsCMCProcessorTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.12', instance => 'processor', descr => 'Processor temperature' },
drsCMCProcessorTemperature => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.12', instance => 'processor', descr => 'Processor temperature' }
};
my $oid_drsChassisStatusGroup = '.1.3.6.1.4.1.674.10892.2.3';
@ -43,23 +43,30 @@ sub check {
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_drsChassisStatusGroup}, instance => '0');
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_drsChassisStatusGroup}, instance => 0);
foreach my $probe (keys %{$mapping}) {
next if (!defined($result->{$probe}));
next if ($self->check_filter(section => 'temperature', instance => $mapping->{$probe}->{instance}));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("%s is %dC [instance: %s].",
$mapping->{$probe}->{descr}, $result->{$probe},
$mapping->{$probe}->{instance}));
$self->{output}->output_add(
long_msg => sprintf(
"%s is %dC [instance: %s].",
$mapping->{$probe}->{descr},
$result->{$probe},
$mapping->{$probe}->{instance}
)
);
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $mapping->{$probe}->{instance}, value => $result->{$probe});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s is %sC", $mapping->{$probe}->{descr}, $result->{$probe}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("%s is %sC", $mapping->{$probe}->{descr}, $result->{$probe})
);
}
$self->{output}->perfdata_add(
label => 'temp', unit => 'C',

View File

@ -0,0 +1,81 @@
#
# Copyright 2021 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::cmc::snmp::mode::components::vdisk;
use strict;
use warnings;
my $map_vdisk_status = {
1 => 'unknown', 2 => 'online',
3 => 'failed', 4 => 'degraded'
};
my $mapping = {
name => { oid => '.1.3.6.1.4.1.674.10892.2.6.1.20.140.1.1.2' }, # virtualDiskName
status => { oid => '.1.3.6.1.4.1.674.10892.2.6.1.20.140.1.1.4', map => $map_vdisk_status } # virtualDiskState
};
my $oid_vdisk_table = '.1.3.6.1.4.1.674.10892.2.6.1.20.140.1'; # virtualDiskTable
sub load {
my ($self) = @_;
push @{$self->{request}}, {
oid => $oid_vdisk_table,
start => $mapping->{name}->{oid},
end => $mapping->{status}->{oid}
};
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking vdisks");
$self->{components}->{vdisk} = { name => 'vdisks', total => 0, skip => 0 };
return if ($self->check_filter(section => 'vdisk'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vdisk_table}})) {
next if ($oid !~ /^$mapping->{name}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_vdisk_table}, instance => $instance);
next if ($self->check_filter(section => 'vdisk', instance => $instance));
$self->{components}->{vdisk}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"vdisk '%s' status is '%s' [instance: %s]",
$result->{name},
$result->{status},
$instance
)
);
my $exit = $self->get_severity(section => 'vdisk', value => $result->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("vdisk '%s' status is '%s'", $result->{name}, $result->{status})
);
}
}
}
1;

View File

@ -34,18 +34,24 @@ sub set_system {
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
health => [
default => [
['other', 'UNKNOWN'],
['unknown', 'UNKNOWN'],
['ok', 'OK'],
['nonCritical', 'WARNING'],
['critical', 'CRITICAL'],
['nonRecoverable', 'CRITICAL']
],
vdisk => [
['online', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
['unknown', 'UNKNOWN']
]
};
$self->{components_path} = 'hardware::server::dell::cmc::snmp::mode::components';
$self->{components_module} = ['health', 'chassis', 'temperature', 'psu'];
$self->{components_module} = ['chassis', 'disk', 'health', 'psu', 'temperature', 'vdisk'];
}
sub snmp_execute {
@ -89,14 +95,14 @@ __END__
=head1 MODE
Check Hardware (Health, Temperatures, Power supplies metrics and chassis metrics).
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'health', 'temperature', 'chassis', 'psu'.
Can be: 'chassis', 'disk', 'health', 'psu', 'temperature', 'vdisk'.
=item B<--filter>