11#
2- # Copyright 2024 Centreon (http://www.centreon.com/)
2+ # Copyright 2026-Present Centreon (http://www.centreon.com/)
33#
44# Centreon is a full-fledged industry-strength solution that meets
55# the needs in IT infrastructure and application monitoring for
@@ -26,6 +26,8 @@ use strict;
2626use warnings;
2727use Digest::MD5 qw( md5_hex) ;
2828use centreon::plugins::templates::catalog_functions qw( catalog_status_threshold_ng) ;
29+ use centreon::plugins::constants qw( :counters :values) ;
30+ use centreon::plugins::misc qw( is_excluded) ;
2931
3032sub prefix_backend_output {
3133 my ($self , %options ) = @_ ;
@@ -43,13 +45,13 @@ sub set_counters {
4345 my ($self , %options ) = @_ ;
4446
4547 $self -> {maps_counters_type } = [
46- { name => ' backend' , type => 1 , cb_prefix_output => ' prefix_backend_output' , message_multiple => ' All backends are ok' }
48+ { name => ' backend' , type => COUNTER_TYPE_INSTANCE , cb_prefix_output => ' prefix_backend_output' , message_multiple => ' All backends are ok' }
4749 ];
4850
4951 $self -> {maps_counters }-> {backend } = [
5052 {
5153 label => ' status' ,
52- type => 2 ,
54+ type => COUNTER_KIND_TEXT ,
5355 critical_default => ' %{status} !~ /UP/i' ,
5456 set => {
5557 key_values => [ { name => ' status' }, { name => ' display' } ],
@@ -132,19 +134,29 @@ my $mapping = {
132134 bytesOUT => { oid => ' .1.3.6.1.4.1.29385.106.1.1.9' },
133135 status => { oid => ' .1.3.6.1.4.1.29385.106.1.1.17' }
134136 },
135- hapee => {
137+ hapee_legacy => {
136138 queueCur => { oid => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.4' },
137139 sessionCur => { oid => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.7' },
138140 sessionTotal => { oid => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.10' },
139141 bytesIN => { oid => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.12' },
140142 bytesOUT => { oid => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.13' },
141143 status => { oid => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.20' }
144+ },
145+ hapee => {
146+ queueCur => { oid => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.4' },
147+ sessionCur => { oid => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.7' },
148+ sessionTotal => { oid => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.10' },
149+ bytesIN => { oid => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.12' },
150+ bytesOUT => { oid => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.13' },
151+ status => { oid => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.20' }
142152 }
153+
143154};
144155my $mapping_name = {
145- csv => ' .1.3.6.1.4.1.29385.106.1.1.0' ,
146- aloha => ' .1.3.6.1.4.1.23263.4.2.1.3.3.1.3' , # alBackendName
147- hapee => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.3' # lbBackendName
156+ csv => ' .1.3.6.1.4.1.29385.106.1.1.0' ,
157+ aloha => ' .1.3.6.1.4.1.23263.4.2.1.3.3.1.3' , # alBackendName
158+ hapee_legacy => ' .1.3.6.1.4.1.23263.4.3.1.3.3.1.3' , # lbBackendName
159+ hapee => ' .1.3.6.1.4.1.58750.4.3.1.3.3.1.3' # lbBackendName
148160};
149161
150162sub manage_selection {
@@ -156,18 +168,17 @@ sub manage_selection {
156168 }
157169
158170 my $snmp_result = $options {snmp }-> get_multiple_table(
159- oids => [
160- { oid => $mapping_name -> {csv } },
161- { oid => $mapping_name -> {aloha } },
162- { oid => $mapping_name -> {hapee } }
163- ],
171+ oids => [ map { { oid => $_ } } values (%$mapping_name ) ],
164172 nothing_quit => 1
165173 );
166174 my $branch = ' aloha' ;
167- if (defined ($snmp_result -> { $mapping_name -> {csv } }) && scalar (keys %{$snmp_result -> { $mapping_name -> {csv } }}) > 0) {
175+
176+ if (defined ($snmp_result -> { $mapping_name -> {csv } }) && keys %{$snmp_result -> { $mapping_name -> {csv } }}) {
168177 $branch = ' csv' ;
169- } elsif (defined ($snmp_result -> { $mapping_name -> {hapee } }) && scalar ( keys %{$snmp_result -> { $mapping_name -> {hapee } }}) > 0 ) {
178+ } elsif (defined ($snmp_result -> { $mapping_name -> {hapee } }) && keys %{$snmp_result -> { $mapping_name -> {hapee } }}) {
170179 $branch = ' hapee' ;
180+ } elsif (defined ($snmp_result -> { $mapping_name -> {hapee_legacy } }) && keys %{$snmp_result -> { $mapping_name -> {hapee_legacy } }}) {
181+ $branch = ' hapee_legacy' ;
171182 }
172183
173184 $self -> {backend } = {};
@@ -176,19 +187,16 @@ sub manage_selection {
176187 my $instance = $1 ;
177188 my $name = $snmp_result -> {$mapping_name -> {$branch }}-> {$oid };
178189
179- if (defined ($self -> {option_results }-> {filter_name }) && $self -> {option_results }-> {filter_name } ne ' ' &&
180- $name !~ / $self ->{option_results}->{filter_name}/ ) {
190+ if (is_excluded($name , $self -> {option_results }-> {filter_name })) {
181191 $self -> {output }-> output_add(long_msg => " skipping backend '" . $name . " '." , debug => 1);
182192 next ;
183193 }
184194
185195 $self -> {backend }-> {$instance } = { display => $name };
186196 }
187197
188- if (scalar (keys %{$self -> {backend }}) <= 0) {
189- $self -> {output }-> add_option_msg(short_msg => " No backend found." );
190- $self -> {output }-> option_exit();
191- }
198+ $self -> {output }-> option_exit(short_msg => " No backend found." )
199+ unless keys %{$self -> {backend }};
192200
193201 $options {snmp }-> load(
194202 oids => [
@@ -242,11 +250,45 @@ You can use the following variables: %{status}, %{display}
242250Define the conditions to match for the status to be CRITICAL (default: '%{status} !~ /UP/i').
243251You can use the following variables: %{status}, %{display}
244252
245- =item B<--warning-* > B<--critical-* >
253+ =item B<--warning-current-queue >
254+
255+ Threshold.
256+
257+ =item B<--critical-current-queue >
258+
259+ Threshold.
260+
261+ =item B<--warning-current-sessions >
262+
263+ Threshold.
264+
265+ =item B<--critical-current-sessions >
266+
267+ Threshold.
268+
269+ =item B<--warning-total-sessions >
270+
271+ Threshold.
272+
273+ =item B<--critical-total-sessions >
274+
275+ Threshold.
276+
277+ =item B<--warning-traffic-in >
278+
279+ Threshold in b/s.
280+
281+ =item B<--critical-traffic-in >
282+
283+ Threshold in b/s.
284+
285+ =item B<--warning-traffic-out >
286+
287+ Threshold in b/s.
288+
289+ =item B<--critical-traffic-out >
246290
247- Thresholds.
248- Can be: 'total-sessions', 'current-sessions', 'current-queue',
249- 'traffic-in' (b/s), 'traffic-out' (b/s).
291+ Threshold in b/s.
250292
251293=back
252294
0 commit comments