| 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::manager; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_conditions = ( |
| 27 |
0 => 'other', # maybe on standby mode only!! |
| 28 |
1 => 'other', |
| 29 |
2 => 'ok', |
| 30 |
3 => 'degraded', |
| 31 |
4 => 'failed', |
| 32 |
); |
| 33 |
|
| 34 |
my %map_role = ( |
| 35 |
1 => 'Standby', |
| 36 |
2 => 'Active', |
| 37 |
); |
| 38 |
|
| 39 |
my $mapping = { |
| 40 |
man_part => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.6' }, # cpqRackCommonEnclosureManagerPartNumber |
| 41 |
man_spare => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.7' }, # cpqRackCommonEnclosureManagerSparePartNumber |
| 42 |
man_serial => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.8' }, # cpqRackCommonEnclosureManagerSerialNum |
| 43 |
man_role => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.9', map => \%map_role }, # cpqRackCommonEnclosureManagerRole |
| 44 |
man_condition => { oid => '.1.3.6.1.4.1.232.22.2.3.1.6.1.12', map => \%map_conditions }, # cpqRackCommonEnclosureManagerConditio |
| 45 |
}; |
| 46 |
|
| 47 |
sub check { |
| 48 |
my ($self, %options) = @_; |
| 49 |
|
| 50 |
$self->{components}->{manager} = { name => 'managers', total => 0, skip => 0 }; |
| 51 |
return if ($self->check_filter(section => 'manager')); |
| 52 |
$self->{output}->output_add(long_msg => "checking managers"); |
| 53 |
|
| 54 |
my $oid_cpqRackCommonEnclosureManagerIndex = '.1.3.6.1.4.1.232.22.2.3.1.6.1.3'; |
| 55 |
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackCommonEnclosureManagerIndex); |
| 56 |
return if (scalar(keys %$snmp_result) <= 0); |
| 57 |
|
| 58 |
my @get_oids = (); |
| 59 |
my @oids_end = (); |
| 60 |
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { |
| 61 |
$key =~ /^$oid_cpqRackCommonEnclosureManagerIndex\.(.*)$/; |
| 62 |
my $oid_end = $1; |
| 63 |
push @oids_end, $oid_end; |
| 64 |
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping)); |
| 65 |
} |
| 66 |
|
| 67 |
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids); |
| 68 |
foreach (@oids_end) { |
| 69 |
my $instance = $_; |
| 70 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 71 |
|
| 72 |
next if ($self->check_filter(section => 'manager', instance => $instance)); |
| 73 |
|
| 74 |
$self->{components}->{manager}->{total}++; |
| 75 |
$self->{output}->output_add(long_msg => sprintf("enclosure management module '%s' is %s, status is %s [serial: %s, part: %s, spare: %s].", |
| 76 |
$instance, $result->{man_condition}, $result->{man_role}, |
| 77 |
$result->{man_serial}, $result->{man_part}, $result->{man_spare})); |
| 78 |
my $exit = $self->get_severity(label => 'default', section => 'manager', instance => $instance, value => $result->{man_condition}); |
| 79 |
if ($result->{man_role} eq 'Active' && !$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 80 |
$self->{output}->output_add(severity => $exit, |
| 81 |
short_msg => sprintf("Enclosure management module '%s' is %s, status is %s", |
| 82 |
$instance, $result->{man_condition}, $result->{man_role})); |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
1; |