| 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::adva::fsp3000::snmp::mode::listinterfaces; |
| 22 |
|
| 23 |
use base qw(snmp_standard::mode::listinterfaces); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
my $mapping = { |
| 29 |
advaInventoryAidString => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.6' }, |
| 30 |
advaInventoryUnitName => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.7' }, |
| 31 |
}; |
| 32 |
|
| 33 |
sub set_oids_label { |
| 34 |
my ($self, %options) = @_; |
| 35 |
|
| 36 |
$self->{oids_label} = { |
| 37 |
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2', |
| 38 |
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18', |
| 39 |
}; |
| 40 |
} |
| 41 |
|
| 42 |
sub default_oid_filter_name { |
| 43 |
my ($self, %options) = @_; |
| 44 |
|
| 45 |
return 'ifdesc'; |
| 46 |
} |
| 47 |
|
| 48 |
sub default_oid_display_name { |
| 49 |
my ($self, %options) = @_; |
| 50 |
|
| 51 |
return 'ifdesc'; |
| 52 |
} |
| 53 |
|
| 54 |
sub new { |
| 55 |
my ($class, %options) = @_; |
| 56 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 57 |
bless $self, $class; |
| 58 |
return $self; |
| 59 |
} |
| 60 |
|
| 61 |
sub manage_selection { |
| 62 |
my ($self, %options) = @_; |
| 63 |
|
| 64 |
$self->SUPER::manage_selection(%options); |
| 65 |
|
| 66 |
my $oid_advaInventoryEntry = '.1.3.6.1.4.1.2544.1.11.7.10.1.1'; |
| 67 |
my $snmp_result = $self->{snmp}->get_table( |
| 68 |
oid => $oid_advaInventoryEntry, |
| 69 |
start => $mapping->{advaInventoryAidString}->{oid}, |
| 70 |
end => $mapping->{advaInventoryUnitName}->{oid} |
| 71 |
); |
| 72 |
|
| 73 |
$self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; |
| 74 |
$self->{results}->{ $self->{extra_oids}->{type} } = {}; |
| 75 |
foreach my $oid (keys %{$snmp_result}) { |
| 76 |
next if ($oid !~ /^$mapping->{advaInventoryUnitName}->{oid}\.(.*)$/); |
| 77 |
my $instance = $1; |
| 78 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 79 |
|
| 80 |
next if ($result->{advaInventoryUnitName} !~ /^(SFP|XFP)/i); |
| 81 |
|
| 82 |
# interface name example: CH-1-3-N1 |
| 83 |
# inventory name example: PL-1-3-N1 |
| 84 |
next if ($result->{advaInventoryAidString} !~ /(\d+-\d+-[^\-]+)$/); |
| 85 |
my $lookup = $1; |
| 86 |
|
| 87 |
foreach (sort @{$self->{interface_id_selected}}) { |
| 88 |
my $display_value = $self->get_display_value(id => $_); |
| 89 |
|
| 90 |
if ($display_value =~ /CH-$lookup$/) { |
| 91 |
$self->{results}->{ $self->{extra_oids}->{type}->{oid} }->{ $self->{extra_oids}->{type}->{oid} . '.' . $_ } = $result->{advaInventoryUnitName}; |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
sub disco_format { |
| 98 |
my ($self, %options) = @_; |
| 99 |
|
| 100 |
$self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; |
| 101 |
$self->SUPER::disco_format(%options); |
| 102 |
} |
| 103 |
|
| 104 |
1; |
| 105 |
|
| 106 |
__END__ |
| 107 |
|
| 108 |
=head1 MODE |
| 109 |
|
| 110 |
=over 8 |
| 111 |
|
| 112 |
=item B<--interface> |
| 113 |
|
| 114 |
Set the interface (number expected) example: 1,2,... (empty means 'check all interfaces'). |
| 115 |
|
| 116 |
=item B<--name> |
| 117 |
|
| 118 |
Allows you to define the interface (in option --interface) by name instead of OID index. The name matching mode supports regular expressions. |
| 119 |
|
| 120 |
=item B<--speed> |
| 121 |
|
| 122 |
Set interface speed (in Mb). |
| 123 |
|
| 124 |
=item B<--skip-speed0> |
| 125 |
|
| 126 |
Don't display interface with speed 0. |
| 127 |
|
| 128 |
=item B<--filter-status> |
| 129 |
|
| 130 |
Display interfaces matching the filter (example: 'up'). |
| 131 |
|
| 132 |
=item B<--use-adminstatus> |
| 133 |
|
| 134 |
Display interfaces with AdminStatus 'up'. |
| 135 |
|
| 136 |
=item B<--oid-filter> |
| 137 |
|
| 138 |
Define the OID to be used to filter interfaces (default: ifDesc) (values: ifDesc, ifAlias). |
| 139 |
|
| 140 |
=item B<--oid-display> |
| 141 |
|
| 142 |
Define the OID that will be used to name the interfaces (default: ifDesc) (values: ifDesc, ifAlias). |
| 143 |
|
| 144 |
=item B<--display-transform-src> B<--display-transform-dst> |
| 145 |
|
| 146 |
Modify the interface name displayed by using a regular expression. |
| 147 |
|
| 148 |
Example: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens' |
| 149 |
|
| 150 |
=item B<--add-extra-oid> |
| 151 |
|
| 152 |
Display an OID. |
| 153 |
Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18' |
| 154 |
or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*' |
| 155 |
|
| 156 |
=back |
| 157 |
|
| 158 |
=cut |