+ Enhance cisco ucs equipment mode (WIP)

This commit is contained in:
garnier-quentin 2015-12-17 11:42:28 +01:00
parent ec19277470
commit ecb978a97b
6 changed files with 299 additions and 5 deletions

View File

@ -0,0 +1,87 @@
#
# Copyright 2015 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::cisco::ucs::mode::components::cpu;
use strict;
use warnings;
use hardware::server::cisco::ucs::mode::components::resources qw(%mapping_presence %mapping_operability);
# In MIB 'CISCO-UNIFIED-COMPUTING-PROCESSOR-MIB'
my $mapping1 = {
cucsProcessorUnitPresence => { oid => '.1.3.6.1.4.1.9.9.719.1.41.9.1.13', map => \%mapping_presence },
};
my $mapping2 = {
cucsProcessorUnitOperState => { oid => '.1.3.6.1.4.1.9.9.719.1.41.9.1.9', map => \%mapping_operability },
};
my $oid_cucsProcessorUnitDn = '.1.3.6.1.4.1.9.9.719.1.41.9.1.2';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping1->{cucsProcessorUnitPresence}->{oid} },
{ oid => $mapping2->{cucsProcessorUnitOperState}->{oid} }, { oid => $oid_cucsProcessorUnitDn };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cpus");
$self->{components}->{cpu} = {name => 'cpus', total => 0, skip => 0};
return if ($self->check_exclude(section => 'cpu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsProcessorUnitDn}})) {
$oid =~ /\.(\d+)$/;
my $instance = $1;
my $cpu_dn = $self->{results}->{$oid_cucsProcessorUnitDn}->{$oid};
my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsProcessorUnitPresence}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsProcessorUnitOperState}->{oid}}, instance => $instance);
next if ($self->absent_problem(section => 'cpu', instance => $cpu_dn));
next if ($self->check_exclude(section => 'cpu', instance => $cpu_dn));
$self->{output}->output_add(long_msg => sprintf("cpu '%s' state is '%s' [presence: %s].",
$cpu_dn, $result2->{cucsProcessorUnitOperState},
$result->{cucsProcessorUnitPresence})
);
my $exit = $self->get_severity(section => 'cpu.presence', label => 'default.presence', value => $result->{cucsProcessorUnitPresence});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("cpu '%s' presence is: '%s'",
$cpu_dn, $result->{cucsProcessorUnitPresence})
);
next;
}
$self->{components}->{cpu}->{total}++;
$exit = $self->get_severity(section => 'cpu.operability', label => 'default.operability', value => $result2->{cucsProcessorUnitOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("cpu '%s' state is '%s'",
$cpu_dn, $result2->{cucsProcessorUnitOperState}
)
);
}
}
}
1;

View File

@ -76,7 +76,7 @@ sub check {
$exit = $self->get_severity(section => 'fan.operability', label => 'default.operability', value => $result2->{cucsEquipmentFanOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' state is '%s'.",
short_msg => sprintf("fan '%s' state is '%s'",
$fan_dn, $result2->{cucsEquipmentFanOperState}
)
);

View File

@ -0,0 +1,87 @@
#
# Copyright 2015 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::cisco::ucs::mode::components::localdisk;
use strict;
use warnings;
use hardware::server::cisco::ucs::mode::components::resources qw(%mapping_presence %mapping_drive_status);
# In MIB 'CISCO-UNIFIED-COMPUTING-STORAGE-MIB'
my $mapping1 = {
cucsStorageLocalDiskPresence => { oid => '.1.3.6.1.4.1.9.9.719.1.45.4.1.10', map => \%mapping_presence },
};
my $mapping2 = {
cucsStorageLocalDiskDiskState => { oid => '.1.3.6.1.4.1.9.9.719.1.45.4.1.18', map => \%mapping_drive_status },
};
my $oid_cucsStorageLocalDiskDn = '.1.3.6.1.4.1.9.9.719.1.30.11.1.2';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping1->{cucsStorageLocalDiskPresence}->{oid} },
{ oid => $mapping2->{cucsStorageLocalDiskDiskState}->{oid} }, { oid => $oid_cucsStorageLocalDiskDn };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking local disks");
$self->{components}->{localdisk} = {name => 'local disks', total => 0, skip => 0};
return if ($self->check_exclude(section => 'localdisk'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsStorageLocalDiskDn}})) {
$oid =~ /\.(\d+)$/;
my $instance = $1;
my $localdisk_dn = $self->{results}->{$oid_cucsStorageLocalDiskDn}->{$oid};
my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsStorageLocalDiskPresence}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsStorageLocalDiskDiskState}->{oid}}, instance => $instance);
next if ($self->absent_problem(section => 'localdisk', instance => $localdisk_dn));
next if ($self->check_exclude(section => 'localdisk', instance => $localdisk_dn));
$self->{output}->output_add(long_msg => sprintf("local disk '%s' state is '%s' [presence: %s].",
$localdisk_dn, $result2->{cucsStorageLocalDiskDiskState},
$result->{cucsStorageLocalDiskPresence})
);
my $exit = $self->get_severity(section => 'localdisk.presence', label => 'default.presence', value => $result->{cucsStorageLocalDiskPresence});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("local disk '%s' presence is: '%s'",
$localdisk_dn, $result->{cucsStorageLocalDiskPresence})
);
next;
}
$self->{components}->{localdisk}->{total}++;
$exit = $self->get_severity(section => 'localdisk.drivestatus', label => 'default.drivestatus', value => $result2->{cucsStorageLocalDiskDiskState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("local disk '%s' state is '%s'",
$localdisk_dn, $result2->{cucsStorageLocalDiskDiskState}
)
);
}
}
}
1;

View File

@ -0,0 +1,87 @@
#
# Copyright 2015 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::cisco::ucs::mode::components::memory;
use strict;
use warnings;
use hardware::server::cisco::ucs::mode::components::resources qw(%mapping_presence %mapping_operability);
# In MIB 'CISCO-UNIFIED-COMPUTING-MEMORY-MIB'
my $mapping1 = {
cucsMemoryUnitPresence => { oid => '.1.3.6.1.4.1.9.9.719.1.30.11.1.17', map => \%mapping_presence },
};
my $mapping2 = {
cucsMemoryUnitOperState => { oid => '.1.3.6.1.4.1.9.9.719.1.30.11.1.13', map => \%mapping_operability },
};
my $oid_cucsMemoryUnitDn = '.1.3.6.1.4.1.9.9.719.1.30.11.1.2';
sub load {
my (%options) = @_;
push @{$options{request}}, { oid => $mapping1->{cucsMemoryUnitPresence}->{oid} },
{ oid => $mapping2->{cucsMemoryUnitOperState}->{oid} }, { oid => $oid_cucsMemoryUnitDn };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking memories");
$self->{components}->{memory} = {name => 'memories', total => 0, skip => 0};
return if ($self->check_exclude(section => 'memory'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsMemoryUnitDn}})) {
$oid =~ /\.(\d+)$/;
my $instance = $1;
my $memory_dn = $self->{results}->{$oid_cucsMemoryUnitDn}->{$oid};
my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsMemoryUnitPresence}->{oid}}, instance => $instance);
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsMemoryUnitOperState}->{oid}}, instance => $instance);
next if ($self->absent_problem(section => 'memory', instance => $memory_dn));
next if ($self->check_exclude(section => 'memory', instance => $memory_dn));
$self->{output}->output_add(long_msg => sprintf("memory '%s' state is '%s' [presence: %s].",
$memory_dn, $result2->{cucsMemoryUnitOperState},
$result->{cucsMemoryUnitPresence})
);
my $exit = $self->get_severity(section => 'memory.presence', label => 'default.presence', value => $result->{cucsMemoryUnitPresence});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("memory '%s' presence is: '%s'",
$memory_dn, $result->{cucsMemoryUnitPresence})
);
next;
}
$self->{components}->{memory}->{total}++;
$exit = $self->get_severity(section => 'memory.operability', label => 'default.operability', value => $result2->{cucsMemoryUnitOperState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("memory '%s' state is '%s'",
$memory_dn, $result2->{cucsMemoryUnitOperState}
)
);
}
}
}
1;

View File

@ -28,10 +28,27 @@ our $thresholds;
our %mapping_presence;
our %mapping_operability;
our %mapping_overall_status;
our %mapping_drive_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($thresholds %mapping_presence %mapping_operability %mapping_overall_status);
our @EXPORT_OK = qw($thresholds %mapping_presence %mapping_operability %mapping_overall_status %mapping_drive_status);
%mapping_drive_status = (
0 => 'unknown',
1 => 'online',
2 => 'unconfiguredGood',
3 => 'globalHotSpare',
4 => 'dedicatedHotSpare',
5 => 'jbod',
6 => 'offline',
7 => 'rebuilding',
8 => 'copyback',
9 => 'failed',
10 => 'unconfiguredBad',
11 => 'predictiveFailure',
12 => 'disabledForRemoval',
13 => 'foreignConfiguration',
);
%mapping_presence = (
0 => 'unknown',
1 => 'empty',
@ -108,6 +125,22 @@ our @EXPORT_OK = qw($thresholds %mapping_presence %mapping_operability %mapping_
);
$thresholds = {
'default.drivestatus' => [
['unknown', 'UNKNOWN'],
['online', 'OK'],
['unconfiguredGood', 'OK'],
['globalHotSpare', 'OK'],
['dedicatedHotSpare', 'OK'],
['jbod', 'OK'],
['offline', 'OK'],
['rebuilding', 'WARNING'],
['copyback', 'OK'],
['failed', 'CRITICAL'],
['unconfiguredBad', 'CRITICAL'],
['predictiveFailure', 'WARNING'],
['disabledForRemoval', 'OK'],
['foreignConfiguration', 'OK'],
],
'default.presence' => [
['unknown', 'UNKNOWN'],
['empty', 'OK'],

View File

@ -79,7 +79,7 @@ sub check_options {
} else {
($section, $instance, $status, $filter) = @values;
}
if ($section !~ /^(fan|psu|chassis|iocard|blade|fex)\.(presence|operability|overall_status)$/) {
if ($section !~ /^(fan|psu|chassis|iocard|blade|fex|cpu|memory|localdisk)\.(presence|operability|overall_status)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload section '" . $val . "'.");
$self->{output}->option_exit();
}
@ -97,7 +97,7 @@ sub run {
$self->{snmp} = $options{snmp};
my $snmp_request = [];
my @components = ('fan', 'psu', 'chassis', 'iocard', 'blade', 'fex');
my @components = ('fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk');
foreach (@components) {
if (/$self->{option_results}->{component}/) {
my $mod_name = "hardware::server::cisco::ucs::mode::components::$_";
@ -221,7 +221,7 @@ Check Hardware (Fans, Power supplies, chassis, io cards, blades, fabric extender
=item B<--component>
Which component to check (Default: '.*').
Can be: 'fan', 'psu', 'chassis', 'iocard', 'blade', 'fex'.
Can be: 'fan', 'psu', 'chassis', 'iocard', 'blade', 'fex', 'cpu', 'memory', 'localdisk'.
=item B<--exclude>