| 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 network::nortel::standard::snmp::mode::components::card; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use network::nortel::standard::snmp::mode::components::resources qw($map_card_status); |
| 26 |
|
| 27 |
my $mapping_rc = { |
| 28 |
serial => { oid => '.1.3.6.1.4.1.2272.1.4.9.1.1.3' }, # rcCardSerialNumber |
| 29 |
status => { oid => '.1.3.6.1.4.1.2272.1.4.9.1.1.6', map => $map_card_status } # rcCardOperStatus |
| 30 |
}; |
| 31 |
my $oid_rcCardEntry = '.1.3.6.1.4.1.2272.1.4.9.1.1'; |
| 32 |
|
| 33 |
my $mapping_rc2k = { |
| 34 |
status => { oid => '.1.3.6.1.4.1.2272.1.100.6.1.5', map => $map_card_status }, # rc2kCardFrontOperStatus |
| 35 |
serial => { oid => '.1.3.6.1.4.1.2272.1.100.6.1.6' } # rc2kCardFrontSerialNum |
| 36 |
}; |
| 37 |
my $oid_rc2kCardEntry = '.1.3.6.1.4.1.2272.1.100.6.1'; |
| 38 |
|
| 39 |
sub load { |
| 40 |
my ($self) = @_; |
| 41 |
|
| 42 |
push @{$self->{request}}, |
| 43 |
{ oid => $oid_rcCardEntry, start => $mapping_rc->{serial}->{oid}, end => $mapping_rc->{serial}->{status} }, |
| 44 |
{ oid => $oid_rc2kCardEntry, start => $mapping_rc2k->{status}->{oid}, end => $mapping_rc2k->{serial}->{status} }; |
| 45 |
} |
| 46 |
|
| 47 |
sub check_rc { |
| 48 |
my ($self) = @_; |
| 49 |
|
| 50 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rcCardEntry}})) { |
| 51 |
next if ($oid !~ /^$mapping_rc->{status}->{oid}\.(.*)$/); |
| 52 |
my $instance = $1; |
| 53 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_rc, results => $self->{results}->{$oid_rcCardEntry}, instance => $instance); |
| 54 |
|
| 55 |
next if ($self->check_filter(section => 'card', instance => $instance)); |
| 56 |
$self->{components}->{card}->{total}++; |
| 57 |
|
| 58 |
$self->{output}->output_add( |
| 59 |
long_msg => sprintf( |
| 60 |
"card '%s' status is '%s' [instance: %s]", |
| 61 |
$result->{serial}, $result->{status}, |
| 62 |
$instance |
| 63 |
) |
| 64 |
); |
| 65 |
my $exit = $self->get_severity(section => 'card', instance => $instance, value => $result->{status}); |
| 66 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 67 |
$self->{output}->output_add( |
| 68 |
severity => $exit, |
| 69 |
short_msg => sprintf( |
| 70 |
"Card '%s' status is '%s'", |
| 71 |
$result->{serial}, $result->{status} |
| 72 |
) |
| 73 |
); |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
sub check_rc2k { |
| 79 |
my ($self) = @_; |
| 80 |
|
| 81 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rc2kCardEntry}})) { |
| 82 |
next if ($oid !~ /^$mapping_rc2k->{status}->{oid}\.(.*)$/); |
| 83 |
my $instance = $1; |
| 84 |
my $result = $self->{snmp}->map_instance(mapping => $mapping_rc2k, results => $self->{results}->{$oid_rc2kCardEntry}, instance => $instance); |
| 85 |
|
| 86 |
next if ($self->check_filter(section => 'card', instance => $instance)); |
| 87 |
$self->{components}->{card}->{total}++; |
| 88 |
|
| 89 |
$self->{output}->output_add( |
| 90 |
long_msg => sprintf( |
| 91 |
"card '%s' status is '%s' [instance: %s]", |
| 92 |
$result->{serial}, $result->{status}, |
| 93 |
$instance |
| 94 |
) |
| 95 |
); |
| 96 |
my $exit = $self->get_severity(section => 'card', instance => $instance, value => $result->{status}); |
| 97 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 98 |
$self->{output}->output_add( |
| 99 |
severity => $exit, |
| 100 |
short_msg => sprintf( |
| 101 |
"Card '%s' status is '%s'", |
| 102 |
$result->{serial}, $result->{status} |
| 103 |
) |
| 104 |
); |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
sub check { |
| 110 |
my ($self) = @_; |
| 111 |
|
| 112 |
$self->{output}->output_add(long_msg => "Checking cards"); |
| 113 |
$self->{components}->{card} = {name => 'cards', total => 0, skip => 0}; |
| 114 |
return if ($self->check_filter(section => 'card')); |
| 115 |
|
| 116 |
check_rc($self); |
| 117 |
check_rc2k($self); |
| 118 |
} |
| 119 |
|
| 120 |
1; |