Debian Codegraph @

src/centreon/common/fortinet/fortigate/snmp/mode/interfaces.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 centreon::common::fortinet::fortigate::snmp::mode::interfaces;
22
23 use base qw(snmp_standard::mode::interfaces);
24
25 use strict;
26 use warnings;
27
28 sub set_oids_label {
29 my ($self, %options) = @_;
30
31 $self->SUPER::set_oids_label(%options);
32 $self->{oids_label}->{vdom} = { oid => '.1.3.6.1.4.1.12356.101.7.2.1.1.1', get => 'reload_get_simple', cache => 'reload_cache_vdom_index' };
33 }
34
35 sub reload_cache_vdom_index {
36 my ($self, %options) = @_;
37
38 my $oid_fgVdEntName = '.1.3.6.1.4.1.12356.101.3.2.1.1.2';
39 my $snmp_result = $self->{snmp}->get_table(oid => $oid_fgVdEntName);
40
41 my $store_index = defined($options{store_index}) && $options{store_index} == 1 ? 1 : 0;
42 foreach (keys %{$options{result}->{ $self->{oids_label}->{$options{name}}->{oid} }}) {
43 /^$self->{oids_label}->{$options{name}}->{oid}\.(.*)$/;
44 push @{$options{datas}->{all_ids}}, $1 if ($store_index == 1);
45
46 $options{datas}->{$options{name} . "_" . $1} = $snmp_result->{ $oid_fgVdEntName . '.' . $options{result}->{ $self->{oids_label}->{$options{name}}->{oid} }->{$_} };
47 }
48 }
49
50 sub new {
51 my ($class, %options) = @_;
52 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
53 bless $self, $class;
54
55 return $self;
56 }
57
58
59 1;
60
61 __END__
62
63 =head1 MODE
64
65 Check interfaces.
66
67 =over 8
68
69 =item B<--add-global>
70
71 Check global port statistics (by default if no --add-* option is set).
72
73 =item B<--add-status>
74
75 Check interface status.
76
77 =item B<--add-duplex-status>
78
79 Check duplex status (with --warning-status and --critical-status).
80
81 =item B<--add-traffic>
82
83 Check interface traffic.
84
85 =item B<--add-errors>
86
87 Check interface errors.
88
89 =item B<--add-cast>
90
91 Check interface cast.
92
93 =item B<--add-speed>
94
95 Check interface speed.
96
97 =item B<--add-volume>
98
99 Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
100
101 =item B<--check-metrics>
102
103 If the expression is true, metrics are checked (default: '%{opstatus} eq "up"').
104
105 =item B<--warning-status>
106
107 Define the conditions to match for the status to be WARNING.
108 You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
109
110 =item B<--critical-status>
111
112 Define the conditions to match for the status to be CRITICAL (default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
113 You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
114
115 =item B<--warning-*> B<--critical-*>
116
117 Thresholds.
118 Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
119 'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
120 'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
121 'speed' (b/s).
122
123 =item B<--units-traffic>
124
125 Units of thresholds for the traffic (default: 'percent_delta') ('percent_delta', 'bps', 'counter').
126
127 =item B<--units-errors>
128
129 Units of thresholds for errors/discards (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
130
131 =item B<--units-cast>
132
133 Units of thresholds for communication types (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
134
135 =item B<--nagvis-perfdata>
136
137 Display traffic perfdata to be compatible with nagvis widget.
138
139 =item B<--interface>
140
141 Set the interface (number expected) example: 1,2,... (empty means 'check all interfaces').
142
143 =item B<--name>
144
145 Allows you to define the interface (in option --interface) by name instead of OID index. The name matching mode supports regular expressions.
146
147 =item B<--speed>
148
149 Set interface speed for incoming/outgoing traffic (in Mb).
150
151 =item B<--speed-in>
152
153 Set interface speed for incoming traffic (in Mb).
154
155 =item B<--speed-out>
156
157 Set interface speed for outgoing traffic (in Mb).
158
159 =item B<--force-counters32>
160
161 Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy.
162
163 =item B<--reload-cache-time>
164
165 Time in minutes before reloading cache file (default: 180).
166
167 =item B<--oid-filter>
168
169 Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr, Vdom).
170
171 =item B<--oid-display>
172
173 Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr, Vdom).
174
175 =item B<--oid-extra-display>
176
177 Add an OID to display.
178
179 =item B<--display-transform-src> B<--display-transform-dst>
180
181 Modify the interface name displayed by using a regular expression.
182
183 Example: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
184
185 =item B<--show-cache>
186
187 Display cache interface data.
188
189 =back
190
191 =cut