Debian Codegraph @

src/centreon/common/ingrian/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 centreon::common::ingrian::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 set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'global', type => 0, message_separator => ' - ' }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'total', set => {
38 key_values => [ { name => 'naeTotalTotalConnections', diff => 1 } ],
39 output_template => 'Total Connections : %s',
40 perfdatas => [
41 { label => 'total', value => 'naeTotalTotalConnections', template => '%s', min => 0 },
42 ],
43 }
44 },
45 { label => 'ssl', set => {
46 key_values => [ { name => 'naeTotalSSLConnections', diff => 1 } ],
47 output_template => 'Total SSL Connections : %s',
48 perfdatas => [
49 { label => 'total_ssl', value => 'naeTotalSSLConnections', template => '%s', min => 0 },
50 ],
51 }
52 },
53 { label => 'non-ssl', set => {
54 key_values => [ { name => 'naeTotalNonSSLConnections', diff => 1 } ],
55 output_template => 'Total non-SSL Connections : %s',
56 perfdatas => [
57 { label => 'total_non_ssl', value => 'naeTotalNonSSLConnections', template => '%s', min => 0 },
58 ],
59 }
60 },
61 ];
62 }
63
64 sub new {
65 my ($class, %options) = @_;
66 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
67 bless $self, $class;
68
69 $options{options}->add_options(arguments =>
70 {
71 });
72
73 return $self;
74 }
75
76 my $mapping = {
77 naeTotalTotalConnections => { oid => '.1.3.6.1.4.1.5595.3.5.1.4' },
78 naeTotalNonSSLConnections => { oid => '.1.3.6.1.4.1.5595.3.5.1.5.4' },
79 naeTotalSSLConnections => { oid => '.1.3.6.1.4.1.5595.3.5.1.6.4' },
80 };
81 my $oid_naeConnectionStats = '.1.3.6.1.4.1.5595.3.5';
82
83 sub manage_selection {
84 my ($self, %options) = @_;
85
86
87 my $snmp_result = $options{snmp}->get_table(oid => $oid_naeConnectionStats,
88 nothing_quit => 1);
89 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
90 $self->{global} = { %$result };
91
92 $self->{cache_name} = "ingrian_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
93 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
94 }
95
96 1;
97
98 __END__
99
100 =head1 MODE
101
102 Check connections.
103
104 =over 8
105
106 =item B<--warning-*>
107
108 Warning threshold.
109 Can be: 'total', 'ssl', 'non-ssl'.
110
111 =item B<--critical-*>
112
113 Critical threshold.
114 Can be: 'total', 'ssl', 'non-ssl'.
115
116 =back
117
118 =cut