| 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::network; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %present_map = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'absent', |
| 29 |
3 => 'present', |
| 30 |
4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB |
| 31 |
); |
| 32 |
|
| 33 |
my %device_type = ( |
| 34 |
1 => 'noconnect', |
| 35 |
2 => 'network', |
| 36 |
3 => 'fibrechannel', |
| 37 |
4 => 'sas', |
| 38 |
5 => 'inifiband', |
| 39 |
6 => 'pciexpress', |
| 40 |
); |
| 41 |
|
| 42 |
my $mapping = { |
| 43 |
nc_model => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.6' }, # cpqRackNetConnectorModel |
| 44 |
nc_serial => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.7' }, # cpqRackNetConnectorSerialNum |
| 45 |
nc_part => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.8' }, # cpqRackNetConnectorPartNumber |
| 46 |
nc_spare => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.9' }, # cpqRackNetConnectorSparePartNumber |
| 47 |
nc_device => { oid => '.1.3.6.1.4.1.232.22.2.6.1.1.1.17', map => \%device_type }, # cpqRackNetConnectorDeviceType |
| 48 |
}; |
| 49 |
|
| 50 |
sub check { |
| 51 |
my ($self) = @_; |
| 52 |
|
| 53 |
$self->{components}->{network} = {name => 'network connectors', total => 0, skip => 0}; |
| 54 |
$self->{output}->output_add(long_msg => "checking network connectors"); |
| 55 |
return if ($self->check_filter(section => 'network')); |
| 56 |
|
| 57 |
my $oid_cpqRackNetConnectorPresent = '.1.3.6.1.4.1.232.22.2.6.1.1.1.13'; |
| 58 |
|
| 59 |
my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackNetConnectorPresent); |
| 60 |
return if (scalar(keys %$snmp_result) <= 0); |
| 61 |
my @get_oids = (); |
| 62 |
my @oids_end = (); |
| 63 |
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { |
| 64 |
next if ($present_map{$snmp_result->{$key}} ne 'present'); |
| 65 |
$key =~ /^$oid_cpqRackNetConnectorPresent\.(.*)$/; |
| 66 |
my $oid_end = $1; |
| 67 |
|
| 68 |
push @oids_end, $oid_end; |
| 69 |
push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping)); |
| 70 |
} |
| 71 |
$snmp_result = $self->{snmp}->get_leef(oids => \@get_oids); |
| 72 |
foreach (@oids_end) { |
| 73 |
my $nc_index = $_; |
| 74 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); |
| 75 |
|
| 76 |
next if ($self->check_filter(section => 'network', instance => $nc_index)); |
| 77 |
|
| 78 |
$self->{components}->{network}->{total}++; |
| 79 |
$self->{output}->output_add( |
| 80 |
long_msg => sprintf("network connector '%s' (%s) type '%s' is present [serial: %s, part: %s, spare: %s].", |
| 81 |
$nc_index, $result->{nc_model}, |
| 82 |
$result->{nc_device}, |
| 83 |
$result->{nc_serial}, $result->{nc_part}, $result->{nc_spare} |
| 84 |
) |
| 85 |
); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
1; |