Debian Codegraph @

src/network/mrv/optiswitch/snmp/mode/listinterfaces.pm

raw
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::mrv::optiswitch::snmp::mode::listinterfaces;
22
23 use base qw(snmp_standard::mode::listinterfaces);
24
25 use strict;
26 use warnings;
27
28 sub set_oids_status {
29 my ($self, %options) = @_;
30
31 $self->{oid_linkstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.5';
32 $self->{oid_linkstatus_mapping} = {
33 1 => 'true', 2 => 'false',
34 };
35 $self->{oid_adminstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.10';
36 $self->{oid_adminstatus_mapping} = {
37 1 => 'other', 2 => 'enable', 3 => 'disableByMgmt',
38 };
39 $self->{oid_opstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.11';
40 $self->{oid_opstatus_mapping} = {
41 1 => 'other', 2 => 'enabled', 3 => 'disabledByMgmt', 4 => 'disabledByReboot', 5 => 'isolatedByLinkFlapGuard',
42 6 => 'isolatedByLinkReflection', 7 => 'isolatedByLinkProtection', 8 => 'isolatedByStpLinkReflection',
43 9 => 'isolatedByHotSwap', 10 => 'isolatedByHa', 11 => 'isolatedByStpPortLoop', 12 => 'isolatedByStpOverRate',
44 13 => 'isolatedByEthoamOverRate', 14 => 'isolatedByEfmOverRate', 15 => 'isolatedByDot1xOverRate',
45 16 => 'isolatedByDot1agOverRate', 17 => 'isolatedByLacpOverRate', 18 => 'isolatedByAhOverRate',
46 19 => 'isolatedByUdld', 20 => 'isolatedByShdslLinkDown',
47 };
48 }
49
50 my $oid_speed64 = '.1.3.6.1.4.1.6926.2.1.2.1.7';
51
52 sub is_admin_status_down {
53 my ($self, %options) = @_;
54
55 if (defined($self->{option_results}->{use_adminstatus}) && defined($options{admin_status}) &&
56 $self->{oid_adminstatus_mapping}->{$options{admin_status}} ne 'enabled') {
57 return 1;
58 }
59 return 0;
60 }
61
62 sub new {
63 my ($class, %options) = @_;
64 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
65
66 bless $self, $class;
67 return $self;
68 }
69
70 1;
71
72 __END__
73
74 =head1 MODE
75
76 =over 8
77
78 =item B<--interface>
79
80 Set the interface (number expected) example: 1,2,... (empty means 'check all interfaces').
81
82 =item B<--name>
83
84 Allows you to define the interface (in option --interface) by name instead of OID index. The name matching mode supports regular expressions.
85
86 =item B<--speed>
87
88 Set interface speed (in Mb).
89
90 =item B<--skip-speed0>
91
92 Don't display interface with speed 0.
93
94 =item B<--filter-status>
95
96 Display interfaces matching the filter (example: 'enabled').
97
98 =item B<--use-adminstatus>
99
100 Display interfaces with AdminStatus 'enabled'.
101
102 =item B<--oid-filter>
103
104 Define the OID to be used to filter interfaces (default: atrConnCepGenDescr) (values: atrConnIngDescr, atrConnCepGenDescr).
105
106 =item B<--oid-display>
107
108 Define the OID that will be used to name the interfaces (default: atrConnCepGenDescr) (values: atrConnIngDescr, atrConnCepGenDescr).
109
110 =item B<--display-transform-src> B<--display-transform-dst>
111
112 Modify the interface name displayed by using a regular expression.
113
114 Example: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
115
116 =item B<--add-extra-oid>
117
118 Display an OID. Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18'
119
120 =back
121
122 =cut