Debian Codegraph @

src/network/stonesoft/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::stonesoft::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, skipped_code => { -10 => 1 } },
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'connections', nlabel => 'connections.total.count', set => {
38 key_values => [ { name => 'fwConnNumber', diff => 1 } ],
39 output_template => 'Connections : %s',
40 perfdatas => [
41 { label => 'connections', template => '%s', unit => 'con', min => 0 },
42 ],
43 }
44 },
45 { label => 'rate-connections', nlabel => 'connections.total.persecond', set => {
46 key_values => [ { name => 'fwConnNumber', per_second => 1 } ],
47 output_template => 'Rate Connections : %.2f /s',
48 perfdatas => [
49 { label => 'rate_connections', template => '%.2f', unit => 'con/s', min => 0 }
50 ],
51 }
52 }
53 ];
54 }
55
56 sub new {
57 my ($class, %options) = @_;
58 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
59 bless $self, $class;
60
61 $options{options}->add_options(arguments => {
62 });
63
64 return $self;
65 }
66
67 sub manage_selection {
68 my ($self, %options) = @_;
69
70 if ($options{snmp}->is_snmpv1()) {
71 $self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
72 $self->{output}->option_exit();
73 }
74
75 my $oid_fwConnNumber = '.1.3.6.1.4.1.1369.5.2.1.4.0';
76 my $snmp_result = $options{snmp}->get_leef(
77 oids => [$oid_fwConnNumber],
78 nothing_quit => 1
79 );
80 $self->{global} = { fwConnNumber => $snmp_result->{$oid_fwConnNumber} };
81
82 $self->{cache_name} = "stonesoft_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
83 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
84 }
85
86 1;
87
88 __END__
89
90 =head1 MODE
91
92 Check firewall connections.
93
94 =over 8
95
96 =item B<--warning-*>
97
98 Warning threshold.
99 Can be: 'connections', 'rate-connections'.
100
101 =item B<--critical-*>
102
103 Critical threshold.
104 Can be: 'connections', 'rate-connections'.
105
106 =back
107
108 =cut