Debian Codegraph @

src/network/a10/ax/snmp/mode/globalstats.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::a10::ax::snmp::mode::globalstats;
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 => 'current-connections', nlabel => 'connections.current.count', set => {
38 key_values => [ { name => 'current_connections' } ],
39 output_template => 'Current Connections : %s',
40 perfdatas => [
41 { label => 'current_connections', value => 'current_connections', template => '%s',
42 min => 0 },
43 ],
44 }
45 },
46 { label => 'total-connections', nlabel => 'connections.total.count', set => {
47 key_values => [ { name => 'total_connections', diff => 1 } ],
48 output_template => 'Total Connections : %s',
49 perfdatas => [
50 { label => 'total_connections', value => 'total_connections', template => '%s',
51 min => 0 },
52 ],
53 }
54 },
55 { label => 'total-ssl-connections', nlabel => 'connections.ssl.total.count', set => {
56 key_values => [ { name => 'total_ssl_connections', diff => 1 } ],
57 output_template => 'Total SSL Connections : %s',
58 perfdatas => [
59 { label => 'total_ssl_connections', value => 'total_ssl_connections', template => '%s',
60 min => 0 },
61 ],
62 }
63 },
64 ];
65 }
66
67 sub new {
68 my ($class, %options) = @_;
69 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
70 bless $self, $class;
71
72 $options{options}->add_options(arguments =>
73 {
74 });
75
76 return $self;
77 }
78
79 sub manage_selection {
80 my ($self, %options) = @_;
81
82 my $oid_axAppGlobalTotalCurrentConnections = '.1.3.6.1.4.1.22610.2.4.3.1.2.1.0';
83 my $oid_axAppGlobalTotalNewConnections = '.1.3.6.1.4.1.22610.2.4.3.1.2.2.0';
84 my $oid_axAppGlobalTotalSSLConnections = '.1.3.6.1.4.1.22610.2.4.3.1.2.6.0';
85 my $result = $options{snmp}->get_leef(oids => [
86 $oid_axAppGlobalTotalCurrentConnections, $oid_axAppGlobalTotalNewConnections,
87 $oid_axAppGlobalTotalSSLConnections,
88 ],
89 nothing_quit => 1);
90 $self->{global} = { current_connections => $result->{$oid_axAppGlobalTotalCurrentConnections},
91 total_connections => $result->{$oid_axAppGlobalTotalNewConnections},
92 total_ssl_connections => $result->{$oid_axAppGlobalTotalSSLConnections},
93 };
94
95 $self->{cache_name} = "a10_ax_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
96 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
97 }
98
99 1;
100
101 __END__
102
103 =head1 MODE
104
105 Check global statistics.
106
107 =over 8
108
109 =item B<--filter-counters>
110
111 Only display some counters (regexp can be used).
112 Example: --filter-counters='^current-connections$'
113
114 =item B<--warning-*>
115
116 Warning threshold.
117 Can be: 'current-connections', 'total-connections'.
118
119 =item B<--critical-*>
120
121 Critical threshold.
122 Can be: 'current-connections', 'total-connections'.
123
124 =back
125
126 =cut