| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package hardware::server::hp::bladechassis::snmp::mode::components::blade; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_conditions = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'ok', |
| 29 |
3 => 'degraded', |
| 30 |
4 => 'failed', |
| 31 |
); |
| 32 |
|
| 33 |
my %present_map = ( |
| 34 |
1 => 'other', |
| 35 |
2 => 'absent', |
| 36 |
3 => 'present', |
| 37 |
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB |
| 38 |
); |
| 39 |
|
| 40 |
my $mapping = { |
| 41 |
blade_name => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.4' }, # cpqRackServerBladeName |
| 42 |
blade_part => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.6' }, # cpqRackServerBladePartNumber |
| 43 |
blade_status => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.21', map => \%map_conditions }, # cpqRackServerBladeStatus (v2) |
| 44 |
blade_spare => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.7' }, # cpqRackServerBladeSparePartNumber |
| 45 |
blade_productid => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.17' }, # cpqRackServerBladeProductId |
| 46 |
blade_diago => { oid => '.1.3.6.1.4.1.232.22.2.4.1.1.1.24' }, # cpqRackServerBladeFaultDiagnosticString (v2) |
| 47 |
}; |
| 48 |
|
| 49 |
sub check { |
| 50 |
my ($self) = @_; |
| 51 |
|
| 52 |
$self->{components}->{blade} = {name => 'blades', total => 0, skip => 0}; |
| 53 |
$self->{output}->output_add(long_msg => "checking blades"); |
| 54 |
return if ($self->check_filter(section => 'blade')); |
| 55 |
|
| 56 |
my $oid_cpqRackServerBladePresent = '.1.3.6.1.4.1.232.22.2.4.1.1.1.12'; |
| 57 |
|
| 58 |
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackServerBladePresent); |
| 59 |
return if (scalar(keys %$snmp_result) <= 0); |
| 60 |
my @get_oids = (); |
| 61 |
my @oids_end = (); |
| 62 |
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { |
| 63 |
$key =~ /\.([0-9]+)$/; |
| 64 |
my $oid_end = $1; |
| 65 |
|
| 66 |
next if ($present_map{$snmp_result->{$key}} ne 'present' && |
| 67 |
$self->absent_problem(section => 'blade', instance => $oid_end)); |
| 68 |
|
| 69 |
push @oids_end, $oid_end; |
| 70 |
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping)); |
| 71 |
} |
| 72 |
|
| 73 |
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids); |
| 74 |
foreach (@oids_end) { |
| 75 |
my $blade_index = $_; |
| 76 |
|
| 77 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $blade_index); |
| 78 |
next if ($self->check_filter(section => 'blade', instance => $blade_index)); |
| 79 |
|
| 80 |
$self->{components}->{blade}->{total}++; |
| 81 |
if (!defined($result->{blade_status})) { |
| 82 |
$self->{output}->output_add(long_msg => sprintf("skipping blade '%s' (%s, %s). Cant get status.", |
| 83 |
$blade_index, $result->{blade_name}, $result->{blade_productid})); |
| 84 |
next; |
| 85 |
} |
| 86 |
|
| 87 |
$self->{output}->output_add( |
| 88 |
long_msg => sprintf("blade '%s' (%s, %s) status is %s [part: %s, spare: %s]%s.", |
| 89 |
$blade_index, $result->{blade_name}, $result->{blade_productid}, |
| 90 |
$result->{blade_status}, |
| 91 |
$result->{blade_part}, $result->{blade_spare}, |
| 92 |
defined($result->{blade_diago}) ? " (Diagnostic '$result->{blade_diago}')" : '' |
| 93 |
) |
| 94 |
); |
| 95 |
my $exit = $self->get_severity(label => 'default', section => 'blade', instance => $blade_index, value => $result->{blade_status}); |
| 96 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 97 |
$self->{output}->output_add( |
| 98 |
severity => $exit, |
| 99 |
short_msg => sprintf("Blade '%s' (%s, %s) status is %s", |
| 100 |
$blade_index, $result->{blade_name}, $result->{blade_productid}, |
| 101 |
$result->{blade_status} |
| 102 |
) |
| 103 |
); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
1; |