| 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::proliant::snmp::mode::components::pnic; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_pnic_condition = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'ok', |
| 29 |
3 => 'degraded', |
| 30 |
4 => 'failed', |
| 31 |
); |
| 32 |
my %map_pnic_role = ( |
| 33 |
1 => "unknown", |
| 34 |
2 => "primary", |
| 35 |
3 => "secondary", |
| 36 |
4 => "member", |
| 37 |
5 => "txRx", |
| 38 |
6 => "tx", |
| 39 |
7 => "standby", |
| 40 |
8 => "none", |
| 41 |
255 => "notApplicable", |
| 42 |
); |
| 43 |
my %map_nic_state = ( |
| 44 |
1 => "unknown", |
| 45 |
2 => "ok", |
| 46 |
3 => "standby", |
| 47 |
4 => "failed", |
| 48 |
); |
| 49 |
my %map_pnic_status = ( |
| 50 |
1 => "unknown", |
| 51 |
2 => "ok", |
| 52 |
3 => "generalFailure", |
| 53 |
4 => "linkFailure", |
| 54 |
); |
| 55 |
my %map_nic_duplex = ( |
| 56 |
1 => "unknown", |
| 57 |
2 => "half", |
| 58 |
3 => "full", |
| 59 |
); |
| 60 |
# In MIB 'CPQNIC-MIB.mib' |
| 61 |
my $mapping = { |
| 62 |
cpqNicIfPhysAdapterRole => { oid => '.1.3.6.1.4.1.232.18.2.3.1.1.3', map => \%map_pnic_role }, |
| 63 |
}; |
| 64 |
my $mapping2 = { |
| 65 |
cpqNicIfPhysAdapterDuplexState => { oid => '.1.3.6.1.4.1.232.18.2.3.1.1.11', map => \%map_nic_duplex }, |
| 66 |
cpqNicIfPhysAdapterCondition => { oid => '.1.3.6.1.4.1.232.18.2.3.1.1.12', map => \%map_pnic_condition }, |
| 67 |
cpqNicIfPhysAdapterState => { oid => '.1.3.6.1.4.1.232.18.2.3.1.1.13', map => \%map_nic_state }, |
| 68 |
cpqNicIfPhysAdapterStatus => { oid => '.1.3.6.1.4.1.232.18.2.3.1.1.14', map => \%map_pnic_status }, |
| 69 |
}; |
| 70 |
my $oid_cpqNicIfPhysAdapterEntry = '.1.3.6.1.4.1.232.18.2.3.1.1'; |
| 71 |
my $oid_cpqNicIfPhysAdapterRole = '.1.3.6.1.4.1.232.18.2.3.1.1.3'; |
| 72 |
|
| 73 |
sub load { |
| 74 |
my ($self) = @_; |
| 75 |
|
| 76 |
push @{$self->{request}}, { oid => $oid_cpqNicIfPhysAdapterEntry, start => $mapping2->{cpqNicIfPhysAdapterDuplexState}->{oid}, end => $mapping2->{cpqNicIfPhysAdapterStatus}->{oid} }, |
| 77 |
{ oid => $oid_cpqNicIfPhysAdapterRole }; |
| 78 |
} |
| 79 |
|
| 80 |
sub check { |
| 81 |
my ($self) = @_; |
| 82 |
|
| 83 |
$self->{output}->output_add(long_msg => "Checking physical nics"); |
| 84 |
$self->{components}->{pnic} = {name => 'physical nics', total => 0, skip => 0}; |
| 85 |
return if ($self->check_filter(section => 'pnic')); |
| 86 |
|
| 87 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqNicIfPhysAdapterEntry}})) { |
| 88 |
next if ($oid !~ /^$mapping2->{cpqNicIfPhysAdapterCondition}->{oid}\.(.*)$/); |
| 89 |
my $instance = $1; |
| 90 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqNicIfPhysAdapterRole}, instance => $instance); |
| 91 |
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqNicIfPhysAdapterEntry}, instance => $instance); |
| 92 |
|
| 93 |
next if ($self->check_filter(section => 'pnic', instance => $instance)); |
| 94 |
$self->{components}->{pnic}->{total}++; |
| 95 |
|
| 96 |
$self->{output}->output_add(long_msg => sprintf("physical nic '%s' [duplex: %s, role: %s, state: %s, status: %s] condition is %s.", |
| 97 |
$instance, $result2->{cpqNicIfPhysAdapterDuplexState}, $result->{cpqNicIfPhysAdapterRole}, |
| 98 |
$result2->{cpqNicIfPhysAdapterState}, $result2->{cpqNicIfPhysAdapterStatus}, |
| 99 |
$result2->{cpqNicIfPhysAdapterCondition})); |
| 100 |
my $exit = $self->get_severity(label => 'default', section => 'pnic', value => $result2->{cpqNicIfPhysAdapterCondition}); |
| 101 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 102 |
$self->{output}->output_add(severity => $exit, |
| 103 |
short_msg => sprintf("physical nic '%s' is %s", |
| 104 |
$instance, $result2->{cpqNicIfPhysAdapterCondition})); |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
1; |