Debian Codegraph @

src/network/sonicwall/snmp/mode/connections.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::sonicwall::snmp::mode::connections;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub set_counters {
29 my ($self, %options) = @_;
30
31 $self->{maps_counters_type} = [
32 { name => 'connections', type => 0 },
33 ];
34 $self->{maps_counters}->{connections} = [
35 { label => 'usage', set => {
36 key_values => [ { name => 'prct_used' }, { name => 'total' }, { name => 'used' } ],
37 closure_custom_output => $self->can('custom_usage_output'),
38 perfdatas => [
39 { label => 'connections', value => 'used', template => '%s',
40 min => 0, max => 'total', threshold_total => 'total', cast_int => 1 },
41 ],
42 }
43 },
44 ];
45 }
46
47 sub custom_usage_output {
48 my ($self, %options) = @_;
49
50 my $msg = sprintf("%.2f%% of the connections cached are used (%d of max. %d)",
51 $self->{result_values}->{prct_used},
52 $self->{result_values}->{used},
53 $self->{result_values}->{total});
54 return $msg;
55 }
56
57 sub new {
58 my ($class, %options) = @_;
59 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
60 bless $self, $class;
61
62 $options{options}->add_options(arguments =>
63 {
64 });
65
66 return $self;
67 }
68
69 sub manage_selection {
70 my ($self, %options) = @_;
71
72 my $oid_sonicMaxConnCacheEntries = '.1.3.6.1.4.1.8741.1.3.1.1.0';
73 my $oid_sonicCurrentConnCacheEntries = '.1.3.6.1.4.1.8741.1.3.1.2.0';
74
75 my $result = $options{snmp}->get_leef(oids => [$oid_sonicMaxConnCacheEntries, $oid_sonicCurrentConnCacheEntries], nothing_quit => 1);
76
77 $self->{connections} = { total => $result->{$oid_sonicMaxConnCacheEntries},
78 used => $result->{$oid_sonicCurrentConnCacheEntries},
79 prct_used => $result->{$oid_sonicCurrentConnCacheEntries} * 100 / $result->{$oid_sonicMaxConnCacheEntries},
80 };
81
82 }
83
84 1;
85
86 __END__
87
88 =head1 MODE
89
90 Check Sonicwall connections usage
91
92 =over 8
93
94 =item B<--warning-usage>
95
96 Warning threshold. Usage (%)
97
98 =item B<--critical-usage>
99
100 Critical threshold. Usage (%)
101
102 =back
103
104 =cut