Debian Codegraph @

src/network/f5/bigip/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::f5::bigip::snmp::mode::connections;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28
29 sub custom_client_tps_calc {
30 my ($self, %options) = @_;
31
32 my $diff_native = $options{new_datas}->{$self->{instance} . '_client_ssl_tot_native'} - $options{old_datas}->{$self->{instance} . '_client_ssl_tot_native'};
33 my $diff_compat = $options{new_datas}->{$self->{instance} . '_client_ssl_tot_compat'} - $options{old_datas}->{$self->{instance} . '_client_ssl_tot_compat'};
34 $self->{result_values}->{client_ssl_tps} = ($diff_native + $diff_compat) / $options{delta_time};
35
36 return 0;
37 }
38
39 sub set_counters {
40 my ($self, %options) = @_;
41
42 $self->{maps_counters_type} = [
43 { name => 'global', type => 0 },
44 ];
45 $self->{maps_counters}->{global} = [
46 { label => 'client', set => {
47 key_values => [ { name => 'client' } ],
48 output_template => 'Current client connections : %s',
49 perfdatas => [
50 { label => 'Client', template => '%s', min => 0, unit => 'con' },
51 ],
52 }
53 },
54 { label => 'client-ssl', set => {
55 key_values => [ { name => 'client_ssl' } ],
56 output_template => 'Current client SSL connections : %s',
57 perfdatas => [
58 { label => 'ClientSSL', template => '%s', min => 0, unit => 'con' },
59 ],
60 }
61 },
62 { label => 'client-ssl-tps', set => {
63 key_values => [ { name => 'client_ssl_tot_native', diff => 1 }, { name => 'client_ssl_tot_compat', diff => 1 } ],
64 output_template => 'TPS client SSL connections : %.2f', threshold_use => 'client_ssl_tps', output_use => 'client_ssl_tps',
65 closure_custom_calc => $self->can('custom_client_tps_calc'),
66 perfdatas => [
67 { label => 'ClientSSL_Tps', value => 'client_ssl_tps', template => '%.2f',
68 unit => 'tps', min => 0 },
69 ],
70 }
71 },
72 { label => 'server', set => {
73 key_values => [ { name => 'server' } ],
74 output_template => 'Current server connections: %s',
75 perfdatas => [
76 { label => 'Server', template => '%s', min => 0, unit => 'con' },
77 ],
78 }
79 },
80 { label => 'server-ssl', set => {
81 key_values => [ { name => 'server_ssl' } ],
82 output_template => 'Current server SSL connections : %s',
83 perfdatas => [
84 { label => 'ServerSSL', template => '%s', min => 0, unit => 'con' },
85 ],
86 }
87 },
88 ];
89 }
90
91 sub new {
92 my ($class, %options) = @_;
93 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
94 bless $self, $class;
95
96 $options{options}->add_options(arguments => {
97 });
98
99 return $self;
100 }
101
102 sub manage_selection {
103 my ($self, %options) = @_;
104
105 $self->{cache_name} = "f5_bipgip_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
106 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
107
108 my $oid_sysStatClientCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.8.0';
109 my $oid_sysStatServerCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.15.0';
110 my $oid_sysClientsslStatCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.9.2.0';
111 my $oid_sysServersslStatCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.10.2.0';
112 my $oid_sysClientsslStatTotNativeConns = '.1.3.6.1.4.1.3375.2.1.1.2.9.6.0';
113 my $oid_sysClientsslStatTotCompatConns = '.1.3.6.1.4.1.3375.2.1.1.2.9.9.0';
114
115 if ($options{snmp}->is_snmpv1()) {
116 $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
117 $self->{output}->option_exit();
118 }
119
120 my $result = $options{snmp}->get_leef(
121 oids => [
122 $oid_sysStatClientCurConns, $oid_sysStatServerCurConns,
123 $oid_sysClientsslStatCurConns, $oid_sysServersslStatCurConns,
124 $oid_sysClientsslStatTotNativeConns, $oid_sysClientsslStatTotCompatConns
125 ],
126 nothing_quit => 1
127 );
128 $self->{global} = {
129 client => $result->{$oid_sysStatClientCurConns},
130 client_ssl => $result->{$oid_sysClientsslStatCurConns},
131 client_ssl_tot_native => $result->{$oid_sysClientsslStatTotNativeConns},
132 client_ssl_tot_compat => $result->{$oid_sysClientsslStatTotCompatConns},
133 server => $result->{$oid_sysStatServerCurConns},
134 server_ssl => $result->{$oid_sysServersslStatCurConns},
135 };
136 }
137
138 1;
139
140 __END__
141
142 =head1 MODE
143
144 Check current connections on F5 BIG IP device.
145
146 =over 8
147
148 =item B<--filter-counters>
149
150 Only display some counters (regexp can be used).
151 Example to check SSL connections only : --filter-counters='^client-ssl|server-ssl$'
152
153 =item B<--warning-*>
154
155 Warning threshold.
156 Can be: 'client', 'server', 'client-ssl', 'server-ssl', 'client-ssl-tps'.
157
158 =item B<--critical-*>
159
160 Critical threshold.
161 Can be: 'client', 'server', 'client-ssl', 'server-ssl', 'client-ssl-tps'.
162
163 =back
164
165 =cut