Debian Codegraph @

src/centreon/common/cisco/standard/snmp/mode/sessions.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 centreon::common::cisco::standard::snmp::mode::sessions;
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 set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'connections', type => 0, cb_prefix_output => 'prefix_connections_output', skipped_code => { -10 => 1 } },
34 { name => 'sessions', type => 0, cb_prefix_output => 'prefix_sessions_output', skipped_code => { -10 => 1 } },
35 ];
36 $self->{maps_counters}->{connections} = [
37 { label => 'connections-current', set => {
38 key_values => [ { name => 'cufwConnGlobalNumActive' } ],
39 output_template => 'current : %s', output_error_template => "current : %s",
40 perfdatas => [
41 { label => 'connections_current', template => '%d', min => 0 },
42 ],
43 }
44 },
45 { label => 'connections-1m', set => {
46 key_values => [ { name => 'cufwConnGlobalConnSetupRate1' } ],
47 output_template => 'average last 1min : %s', output_error_template => "average last 1min : %s",
48 perfdatas => [
49 { label => 'connections_1m', template => '%d', min => 0 },
50 ],
51 }
52 },
53 { label => 'connections-5m', set => {
54 key_values => [ { name => 'cufwConnGlobalConnSetupRate5' } ],
55 output_template => 'average last 5min : %s', output_error_template => "average last 5min : %s",
56 perfdatas => [
57 { label => 'connections_5m', template => '%d', min => 0 },
58 ],
59 }
60 },
61 ];
62
63 $self->{maps_counters}->{sessions} = [
64 { label => 'sessions-total', set => {
65 key_values => [ { name => 'crasNumSessions' } ],
66 output_template => 'total : %s', output_error_template => "total : %s",
67 perfdatas => [
68 { label => 'sessions_total', template => '%d', min => 0 },
69 ],
70 }
71 },
72 { label => 'sessions-email-current', set => {
73 key_values => [ { name => 'crasEmailNumSessions' } ],
74 output_template => 'current email proxy : %s', output_error_template => "current email proxy : %s",
75 perfdatas => [
76 { label => 'sessions_email_current', template => '%d', min => 0 },
77 ],
78 }
79 },
80 { label => 'sessions-email-psec', set => {
81 key_values => [ { name => 'crasEmailCumulateSessions', per_second => 1 } ],
82 output_template => 'email proxy : %.2f/s', output_error_template => "email proxy : %s",
83 perfdatas => [
84 { label => 'sessions_email_psec', template => '%.2f', min => 0 },
85 ],
86 }
87 },
88 { label => 'sessions-ipsec-current', set => {
89 key_values => [ { name => 'crasIPSecNumSessions' } ],
90 output_template => 'current ipsec : %s', output_error_template => "current ipsec : %s",
91 perfdatas => [
92 { label => 'sessions_ipsec_current', template => '%d', min => 0 },
93 ],
94 }
95 },
96 { label => 'sessions-ipsec-psec', set => {
97 key_values => [ { name => 'crasIPSecCumulateSessions', per_second => 1 } ],
98 output_template => 'ipsec : %.2f/s', output_error_template => "ipsec : %s",
99 perfdatas => [
100 { label => 'sessions_ipsec_psec', template => '%.2f', min => 0 },
101 ],
102 }
103 },
104 { label => 'sessions-l2l-current', set => {
105 key_values => [ { name => 'crasL2LNumSessions' } ],
106 output_template => 'current LAN to LAN : %s', output_error_template => "current LAN to LAN : %s",
107 perfdatas => [
108 { label => 'sessions_l2l_current', template => '%d', min => 0 },
109 ],
110 }
111 },
112 { label => 'sessions-l2l-psec', set => {
113 key_values => [ { name => 'crasL2LCumulateSessions', per_second => 1 } ],
114 output_template => 'LAN to LAN : %.2f/s', output_error_template => "LAN to LAN : %s",
115 perfdatas => [
116 { label => 'sessions_l2l_psec', template => '%.2f', min => 0 },
117 ],
118 }
119 },
120 { label => 'sessions-lb-current', set => {
121 key_values => [ { name => 'crasLBNumSessions' } ],
122 output_template => 'current load balancing : %s', output_error_template => "current load balancing : %s",
123 perfdatas => [
124 { label => 'sessions_lb_current', template => '%d', min => 0 },
125 ],
126 }
127 },
128 { label => 'sessions-lb-psec', set => {
129 key_values => [ { name => 'crasLBCumulateSessions', per_second => 1 } ],
130 output_template => 'load balancing : %.2f/s', output_error_template => "load balancing : %s",
131 perfdatas => [
132 { label => 'sessions_lb_psec', template => '%.2f', min => 0 },
133 ],
134 }
135 },
136 { label => 'sessions-svc-current', set => {
137 key_values => [ { name => 'crasSVCNumSessions' } ],
138 output_template => 'current SVC : %s', output_error_template => "current SVC : %s",
139 perfdatas => [
140 { label => 'sessions_svc_current', template => '%d', min => 0 },
141 ],
142 }
143 },
144 { label => 'sessions-svc-psec', set => {
145 key_values => [ { name => 'crasSVCCumulateSessions', per_second => 1 } ],
146 output_template => 'SVC : %.2f/s', output_error_template => "SVC : %s",
147 perfdatas => [
148 { label => 'sessions_svc_psec', template => '%.2f', min => 0 },
149 ],
150 }
151 },
152 { label => 'sessions-webvpn-current', set => {
153 key_values => [ { name => 'crasWebvpnNumSessions' } ],
154 output_template => 'current webvpn : %s', output_error_template => "current webvpn : %s",
155 perfdatas => [
156 { label => 'sessions_webvpn_current', template => '%d', min => 0 },
157 ],
158 }
159 },
160 { label => 'sessions-webvpn-psec', set => {
161 key_values => [ { name => 'crasWebvpnCumulateSessions', per_second => 1 } ],
162 output_template => 'webvpn : %.2f/s', output_error_template => "webvpn : %s",
163 perfdatas => [
164 { label => 'sessions_webvpn_psec',template => '%.2f', min => 0 },
165 ],
166 }
167 },
168 ];
169 }
170
171 sub prefix_connections_output {
172 my ($self, %options) = @_;
173
174 return "Connections ";
175 }
176
177 sub prefix_sessions_output {
178 my ($self, %options) = @_;
179
180 return "Sessions ";
181 }
182
183 sub new {
184 my ($class, %options) = @_;
185 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
186 bless $self, $class;
187
188 $options{options}->add_options(arguments => {
189 });
190
191 return $self;
192 }
193
194 my %oids_connections = (
195 cufwConnGlobalNumActive => '.1.3.6.1.4.1.9.9.491.1.1.1.6.0',
196 cufwConnGlobalConnSetupRate1 => '.1.3.6.1.4.1.9.9.491.1.1.1.10.0',
197 cufwConnGlobalConnSetupRate5 => '.1.3.6.1.4.1.9.9.491.1.1.1.11.0',
198 );
199 my %oids_sessions = (
200 crasNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.1.0',
201 crasEmailNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.23.0',
202 crasEmailCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.24.0',
203 crasIPSecNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.26.0',
204 crasIPSecCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.27.0',
205 crasL2LNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.29.0',
206 crasL2LCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.30.0',
207 crasLBNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.32.0',
208 crasLBCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.33.0',
209 crasSVCNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.35.0',
210 crasSVCCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.36.0',
211 crasWebvpnNumSessions => '.1.3.6.1.4.1.9.9.392.1.3.38.0',
212 crasWebvpnCumulateSessions => '.1.3.6.1.4.1.9.9.392.1.3.39.0',
213 );
214
215 sub manage_selection {
216 my ($self, %options) = @_;
217
218 $self->{cache_name} = "cisco_standard_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
219 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
220
221 $self->{connections} = {};
222 $self->{sessions} = {};
223
224 $self->{results} = $options{snmp}->get_leef(oids => [values %oids_connections, values %oids_sessions],
225 nothing_quit => 1);
226 foreach my $name (keys %oids_connections) {
227 next if (!defined($self->{results}->{$oids_connections{$name}}) || $self->{results}->{$oids_connections{$name}} == 0);
228 $self->{connections}->{$name} = $self->{results}->{$oids_connections{$name}};
229 }
230 foreach my $name (keys %oids_sessions) {
231 next if (!defined($self->{results}->{$oids_sessions{$name}}) || $self->{results}->{$oids_sessions{$name}} == 0);
232 $self->{sessions}->{$name} = $self->{results}->{$oids_sessions{$name}};
233 }
234 }
235
236 1;
237
238 __END__
239
240 =head1 MODE
241
242 Check sessions.
243
244 =over 8
245
246 =item B<--warning-*>
247
248 Warning threshold.
249 Can be: 'connections-current', 'connections-1m', 'connections-5m',
250 'sessions-total', 'sessions-email-current', 'sessions-email-psec',
251 'sessions-ipsec-current', 'sessions-ipsec-psec', 'sessions-l2l-current', 'sessions-lb-psec'
252 'sessions-lb-current', 'sessions-lb-psec', 'sessions-svc-current', 'sessions-svc-psec',
253 'sessions-webvpn-current', 'sessions-webvpn-psec'.
254
255 =item B<--critical-*>
256
257 Critical threshold.
258 Can be: 'connections-current', 'connections-1m', 'connections-5m',
259 'sessions-total', 'sessions-email-current', 'sessions-email-psec',
260 'sessions-ipsec-current', 'sessions-ipsec-psec', 'sessions-l2l-current', 'sessions-lb-psec'
261 'sessions-lb-current', 'sessions-lb-psec', 'sessions-svc-current', 'sessions-svc-psec',
262 'sessions-webvpn-current', 'sessions-webvpn-psec'.
263
264 =back
265
266 =cut