| 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::lnic; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use centreon::plugins::misc; |
| 26 |
|
| 27 |
my %map_lnic_condition = ( |
| 28 |
1 => 'other', |
| 29 |
2 => 'ok', |
| 30 |
3 => 'degraded', |
| 31 |
4 => 'failed', |
| 32 |
); |
| 33 |
my %map_lnic_status = ( |
| 34 |
1 => "unknown", |
| 35 |
2 => "ok", |
| 36 |
3 => "primaryFailed", |
| 37 |
4 => "standbyFailed", |
| 38 |
5 => "groupFailed", |
| 39 |
6 => "redundancyReduced", |
| 40 |
7 => "redundancyLost", |
| 41 |
); |
| 42 |
|
| 43 |
# In MIB 'CPQNIC-MIB.mib' |
| 44 |
my $mapping = { |
| 45 |
cpqNicIfLogMapDescription => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.3' }, |
| 46 |
}; |
| 47 |
my $mapping2 = { |
| 48 |
cpqNicIfLogMapAdapterCount => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.5' }, |
| 49 |
}; |
| 50 |
my $mapping3 = { |
| 51 |
cpqNicIfLogMapCondition => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.10', map => \%map_lnic_condition }, |
| 52 |
cpqNicIfLogMapStatus => { oid => '.1.3.6.1.4.1.232.18.2.2.1.1.11', map => \%map_lnic_status }, |
| 53 |
}; |
| 54 |
my $oid_cpqNicIfLogMapEntry = '.1.3.6.1.4.1.232.18.2.2.1.1'; |
| 55 |
my $oid_cpqNicIfLogMapDescription = '.1.3.6.1.4.1.232.18.2.2.1.1.3'; |
| 56 |
my $oid_cpqNicIfLogMapAdapterCount = '.1.3.6.1.4.1.232.18.2.2.1.1.5'; |
| 57 |
|
| 58 |
sub load { |
| 59 |
my ($self) = @_; |
| 60 |
|
| 61 |
push @{$self->{request}}, { oid => $oid_cpqNicIfLogMapEntry, start => $mapping3->{cpqNicIfLogMapCondition}->{oid}, end => $mapping3->{cpqNicIfLogMapStatus}->{oid} }, |
| 62 |
{ oid => $oid_cpqNicIfLogMapDescription }, { oid => $oid_cpqNicIfLogMapAdapterCount }; |
| 63 |
} |
| 64 |
|
| 65 |
sub check { |
| 66 |
my ($self) = @_; |
| 67 |
|
| 68 |
$self->{output}->output_add(long_msg => "Checking logical nics"); |
| 69 |
$self->{components}->{lnic} = {name => 'logical nics', total => 0, skip => 0}; |
| 70 |
return if ($self->check_filter(section => 'lnic')); |
| 71 |
|
| 72 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqNicIfLogMapEntry}})) { |
| 73 |
next if ($oid !~ /^$mapping3->{cpqNicIfLogMapCondition}->{oid}\.(.*)$/); |
| 74 |
my $instance = $1; |
| 75 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqNicIfLogMapDescription}, instance => $instance); |
| 76 |
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqNicIfLogMapAdapterCount}, instance => $instance); |
| 77 |
my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_cpqNicIfLogMapEntry}, instance => $instance); |
| 78 |
|
| 79 |
next if ($self->check_filter(section => 'lnic', instance => $instance)); |
| 80 |
$self->{components}->{lnic}->{total}++; |
| 81 |
|
| 82 |
$self->{output}->output_add(long_msg => sprintf("logical nic '%s' [adapter count: %s, description: %s, status: %s] condition is %s.", |
| 83 |
$instance, $result2->{cpqNicIfLogMapAdapterCount}, centreon::plugins::misc::trim($result->{cpqNicIfLogMapDescription}), |
| 84 |
$result3->{cpqNicIfLogMapStatus}, |
| 85 |
$result3->{cpqNicIfLogMapCondition})); |
| 86 |
my $exit = $self->get_severity(section => 'lnic', value => $result3->{cpqNicIfLogMapCondition}); |
| 87 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 88 |
$self->{output}->output_add(severity => $exit, |
| 89 |
short_msg => sprintf("logical nic '%s' is %s", |
| 90 |
$instance, $result3->{cpqNicIfLogMapCondition})); |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
1; |