Debian Codegraph @

src/network/aruba/aoscx/snmp/mode/vsx.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::aruba::aoscx::snmp::mode::vsx;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
29
30 sub custom_device_status_output {
31 my ($self, %options) = @_;
32
33 return sprintf(
34 'role: %s [config sync: %s]',
35 $self->{result_values}->{role},
36 $self->{result_values}->{config_sync}
37 );
38 }
39
40 sub custom_isl_status_output {
41 my ($self, %options) = @_;
42
43 return sprintf(
44 'status: %s',
45 $self->{result_values}->{isl_status}
46 );
47 }
48
49 sub custom_keepalive_status_output {
50 my ($self, %options) = @_;
51
52 return sprintf(
53 'status: %s',
54 $self->{result_values}->{keepalive_status}
55 );
56 }
57
58 sub vsx_long_output {
59 my ($self, %options) = @_;
60
61 return 'checking virtual switching extension';
62 }
63
64 sub prefix_vsx_output {
65 my ($self, %options) = @_;
66
67 return 'Virtual switching extension ';
68 }
69
70 sub prefix_isl_output {
71 my ($self, %options) = @_;
72
73 return 'inter-switch link ';
74 }
75
76 sub prefix_keepalive_output {
77 my ($self, %options) = @_;
78
79 return 'keepalive ';
80 }
81
82 sub prefix_device_output {
83 my ($self, %options) = @_;
84
85 return 'device ';
86 }
87
88 sub set_counters {
89 my ($self, %options) = @_;
90
91 $self->{maps_counters_type} = [
92 { name => 'vsx', type => 3, cb_prefix_output => 'prefix_vsx_output', cb_long_output => 'vsx_long_output', indent_long_output => ' ',
93 group => [
94 { name => 'device', type => 0, display_short => 0, cb_prefix_output => 'prefix_device_output', skipped_code => { -10 => 1 } },
95 { name => 'isl', type => 0, display_short => 0, cb_prefix_output => 'prefix_isl_output', skipped_code => { -10 => 1 } },
96 { name => 'keepalive', type => 0, display_short => 0, cb_prefix_output => 'prefix_keepalive_output', skipped_code => { -10 => 1 } }
97 ]
98 }
99 ];
100
101 $self->{maps_counters}->{device} = [
102 {
103 label => 'device-status',
104 type => 2,
105 set => {
106 key_values => [ { name => 'role' }, { name => 'config_sync' } ],
107 closure_custom_output => $self->can('custom_device_status_output'),
108 closure_custom_perfdata => sub { return 0; },
109 closure_custom_threshold_check => \&catalog_status_threshold_ng
110 }
111 }
112 ];
113
114 $self->{maps_counters}->{isl} = [
115 {
116 label => 'isl-status',
117 type => 2,
118 critical_default => '%{isl_status} =~ /outSync/',
119 set => {
120 key_values => [ { name => 'isl_status' } ],
121 closure_custom_output => $self->can('custom_isl_status_output'),
122 closure_custom_perfdata => sub { return 0; },
123 closure_custom_threshold_check => \&catalog_status_threshold_ng
124 }
125 },
126 { label => 'isl-packets-in', nlabel => 'vsx.isl.packets.in.count', set => {
127 key_values => [ { name => 'isl_packets_in', diff => 1 } ],
128 output_template => 'packets in: %s',
129 perfdatas => [
130 { template => '%s', min => 0 }
131 ]
132 }
133 },
134 { label => 'isl-packets-out', nlabel => 'vsx.isl.packets.out.count', set => {
135 key_values => [ { name => 'isl_packets_out', diff => 1 } ],
136 output_template => 'packets out: %s',
137 perfdatas => [
138 { template => '%s', min => 0 }
139 ]
140 }
141 }
142 ];
143
144 $self->{maps_counters}->{keepalive} = [
145 {
146 label => 'keepalive-status',
147 type => 2,
148 critical_default => '%{keepalive_status} =~ /outofSyncEstablished|failed/',
149 set => {
150 key_values => [ { name => 'keepalive_status' } ],
151 closure_custom_output => $self->can('custom_keepalive_status_output'),
152 closure_custom_perfdata => sub { return 0; },
153 closure_custom_threshold_check => \&catalog_status_threshold_ng
154 }
155 },
156 { label => 'keepalive-packets-in', nlabel => 'vsx.keepalive.packets.in.count', set => {
157 key_values => [ { name => 'keepalive_packets_in', diff => 1 } ],
158 output_template => 'packets in: %s',
159 perfdatas => [
160 { template => '%s', min => 0 }
161 ]
162 }
163 },
164 { label => 'keepalive-packets-out', nlabel => 'vsx.keepalive.packets.out.count', set => {
165 key_values => [ { name => 'keepalive_packets_out', diff => 1 } ],
166 output_template => 'packets out: %s',
167 perfdatas => [
168 { template => '%s', min => 0 }
169 ]
170 }
171 }
172 ];
173 }
174
175 sub new {
176 my ($class, %options) = @_;
177 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
178 bless $self, $class;
179
180 $options{options}->add_options(arguments => {
181 });
182
183 return $self;
184 }
185
186 my $mapping_role = {
187 1 => 'primary', 2 => 'secondary', 3 => 'notConfigured'
188 };
189 my $mapping_config_sync = {
190 1 => 'enabled', 2 => 'disabled'
191 };
192 my $mapping_isl_state = {
193 1 => 'init', 2 => 'outSync', 3 => 'inSync'
194 };
195 my $mapping_keepalive_state = {
196 1 => 'init', 2 => 'configured', 3 => 'inSyncEstablished',
197 4 => 'outofSyncEstablished', 5 => 'initEstablished',
198 6 => 'failed', 7 => 'stopped'
199 };
200
201 my $mapping = {
202 role => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.1.4.1', map => $mapping_role }, # arubaWiredVsxDeviceRole
203 config_sync => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.1.4.2', map => $mapping_config_sync }, # arubaWiredVsxConfigSync
204 isl_status => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.1.1', map => $mapping_isl_state }, # arubaWiredVsxIslOperState
205 isl_packets_out => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.1.2' }, # arubaWiredVsxIslPduTx
206 isl_packets_in => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.1.3' }, # arubaWiredVsxIslPduRx
207 keepalive_status => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.2.1', map => $mapping_keepalive_state }, # arubaWiredVsxKeepAliveOperState
208 keepalive_packets_out => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.2.2' }, # arubaWiredVsxKeepAlivePacketsTx
209 keepalive_packets_in => { oid => '.1.3.6.1.4.1.47196.4.1.1.3.7.2.2.3' } # arubaWiredVsxKeepAlivePacketsRx
210 };
211
212 sub manage_selection {
213 my ($self, %options) = @_;
214
215 my $snmp_result = $options{snmp}->get_leef(oids => [ map($_->{oid} . '.0', values(%$mapping)) ], nothing_quit => 1);
216 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
217
218 $self->{output}->output_add(short_msg => 'virtual switching extension is ok');
219
220 $self->{vsx} = {
221 global => {
222 device => {
223 role => $result->{role},
224 config_sync => $result->{config_sync}
225 },
226 isl => {
227 isl_status => $result->{isl_status},
228 isl_packets_out => $result->{isl_packets_out},
229 isl_packets_in => $result->{isl_packets_in}
230 },
231 keepalive => {
232 keepalive_status => $result->{keepalive_status},
233 keepalive_packets_out => $result->{keepalive_packets_out},
234 keepalive_packets_in => $result->{keepalive_packets_in}
235 }
236 }
237 };
238
239 $self->{cache_name} = 'aruba_aoscx_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
240 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
241 }
242
243 1;
244
245 __END__
246
247 =head1 MODE
248
249 Check virtual switching extension.
250
251 =over 8
252
253 =item B<--unknown-device-status>
254
255 Define the conditions to match for the status to be UNKNOWN.
256 You can use the following variables: %{role}, %{config_sync}
257
258 =item B<--warning-device-status>
259
260 Define the conditions to match for the status to be WARNING.
261 You can use the following variables: %{role}, %{config_sync}
262
263 =item B<--critical-device-status>
264
265 Define the conditions to match for the status to be CRITICAL.
266 You can use the following variables: %{role}, %{config_sync}
267
268 =item B<--unknown-isl-status>
269
270 Define the conditions to match for the status to be UNKNOWN.
271 You can use the following variables: %{isl_status}
272
273 =item B<--warning-isl-status>
274
275 Define the conditions to match for the status to be WARNING.
276 You can use the following variables: %{isl_status}
277
278 =item B<--critical-isl-status>
279
280 Define the conditions to match for the status to be CRITICAL (default: '%{isl_status} =~ /outSync/').
281 You can use the following variables: %{isl_status}
282
283 =item B<--unknown-keepalive-status>
284
285 Define the conditions to match for the status to be UNKNOWN.
286 You can use the following variables: %{keepalive_status}
287
288 =item B<--warning-keepalive-status>
289
290 Define the conditions to match for the status to be WARNING.
291 You can use the following variables: %{keepalive_status}
292
293 =item B<--critical-keepalive-status>
294
295 Define the conditions to match for the status to be CRITICAL (default: '%{keepalive_status} =~ /outofSyncEstablished|failed/').
296 You can use the following variables: %{keepalive_status}
297
298 =item B<--warning-*> B<--critical-*>
299
300 Thresholds.
301 Can be: 'isl-packets-in', 'isl-packets-out', 'keepalive-packets-in', 'keepalive-packets-out'.
302
303 =back
304
305 =cut