Debian Codegraph @

src/network/aruba/aoscx/restapi/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::restapi::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} =~ /out_sync/',
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_in', 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} =~ /out_of_sync_established|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_in', 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 sub manage_selection {
187 my ($self, %options) = @_;
188
189 my $vsx = $options{custom}->request(endpoint => '/system/vsx');
190
191 $self->{output}->output_add(short_msg => 'virtual switching extension is ok');
192
193 $self->{vsx} = {
194 global => {
195 device => {
196 role => $vsx->{device_role},
197 config_sync => $vsx->{config_sync_disable} =~ /False|1/ ? 'disabled' : 'enabled'
198 },
199 isl => {
200 isl_status => $vsx->{oper_status}->{islp_link_state},
201 isl_packets_out => $vsx->{isl_statistics}->{pdu_tx},
202 isl_packets_in => $vsx->{isl_statistics}->{pdu_rx}
203 },
204 keepalive => {
205 keepalive_status => $vsx->{keepalive_status}->{state},
206 keepalive_packets_out => $vsx->{keepalive_statistics}->{tx},
207 keepalive_packets_in => $vsx->{keepalive_statistics}->{rx}
208 }
209 }
210 };
211
212 $self->{cache_name} = 'aruba_aoscx_' . $self->{mode} . '_' . $options{custom}->get_connection_infos() . '_' .
213 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
214 }
215
216 1;
217
218 __END__
219
220 =head1 MODE
221
222 Check virtual switching extension.
223
224 =over 8
225
226 =item B<--unknown-device-status>
227
228 Define the conditions to match for the status to be UNKNOWN.
229 You can use the following variables: %{role}, %{config_sync}
230
231 =item B<--warning-device-status>
232
233 Define the conditions to match for the status to be WARNING.
234 You can use the following variables: %{role}, %{config_sync}
235
236 =item B<--critical-device-status>
237
238 Define the conditions to match for the status to be CRITICAL.
239 You can use the following variables: %{role}, %{config_sync}
240
241 =item B<--unknown-isl-status>
242
243 Define the conditions to match for the status to be UNKNOWN.
244 You can use the following variables: %{isl_status}
245
246 =item B<--warning-isl-status>
247
248 Define the conditions to match for the status to be WARNING.
249 You can use the following variables: %{isl_status}
250
251 =item B<--critical-isl-status>
252
253 Define the conditions to match for the status to be CRITICAL (default: '%{isl_status} =~ /out_sync/').
254 You can use the following variables: %{isl_status}
255
256 =item B<--unknown-keepalive-status>
257
258 Define the conditions to match for the status to be UNKNOWN.
259 You can use the following variables: %{keepalive_status}
260
261 =item B<--warning-keepalive-status>
262
263 Define the conditions to match for the status to be WARNING.
264 You can use the following variables: %{keepalive_status}
265
266 =item B<--critical-keepalive-status>
267
268 Define the conditions to match for the status to be CRITICAL (default: '%{keepalive_status} =~ /out_of_sync_established|failed/').
269 You can use the following variables: %{keepalive_status}
270
271 =item B<--warning-*> B<--critical-*>
272
273 Thresholds.
274 Can be: 'isl-packets-in', 'isl-packets-out', 'keepalive-packets-in', 'keepalive-packets-out'.
275
276 =back
277
278 =cut