Debian Codegraph @

src/network/fortinet/fortiweb/snmp/mode/proxy.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::fortinet::fortiweb::snmp::mode::proxy;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub system_long_output {
29 my ($self, %options) = @_;
30
31 return 'checking proxy';
32 }
33
34 sub prefix_connections_output {
35 my ($self, %options) = @_;
36
37 return 'number of connections ';
38 }
39
40 sub set_counters {
41 my ($self, %options) = @_;
42
43 $self->{maps_counters_type} = [
44 { name => 'proxy', type => 3, cb_long_output => 'proxy_long_output', indent_long_output => ' ',
45 group => [
46 { name => 'connection', type => 0, cb_prefix_output => 'prefix_connections_output', display_short => 0, skipped_code => { -10 => 1 } },
47 { name => 'service', type => 0, display_short => 0, skipped_code => { -10 => 1 } }
48 ]
49 }
50 ];
51
52 $self->{maps_counters}->{connection} = [
53 { label => 'connections', nlabel => 'proxy.connections.count', set => {
54 key_values => [ { name => 'con_current' } ],
55 output_template => 'current: %s',
56 perfdatas => [
57 { template => '%s', min => 0 }
58 ]
59 }
60 },
61 { label => 'connections-average', nlabel => 'proxy.connections.persecond', set => {
62 key_values => [ { name => 'con_psec' } ],
63 output_template => 'average: %s/s',
64 perfdatas => [
65 { template => '%s', unit => '/s', min => 0 }
66 ]
67 }
68 },
69 ];
70
71 $self->{maps_counters}->{service} = [
72 { label => 'services', nlabel => 'proxy.services.count', set => {
73 key_values => [ { name => 'services_num' } ],
74 output_template => 'number of services: %s',
75 perfdatas => [
76 { template => '%s', min => 0 }
77 ]
78 }
79 }
80 ];
81 }
82
83 sub new {
84 my ($class, %options) = @_;
85 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
86 bless $self, $class;
87
88 $options{options}->add_options(arguments => {
89 });
90
91 return $self;
92 }
93
94 sub manage_selection {
95 my ($self, %options) = @_;
96
97 my $mapping = {
98 services_num => { oid => '.1.3.6.1.4.1.12356.107.3.5' }, # fwServiceNumber
99 con_current => { oid => '.1.3.6.1.4.1.12356.107.3.7' }, # fwTotalConnectNumber
100 con_psec => { oid => '.1.3.6.1.4.1.12356.107.3.8' } # fwTotalConnectNumberPerSecond
101 };
102
103 my $snmp_result = $options{snmp}->get_leef(
104 oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
105 nothing_quit => 1
106 );
107 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
108
109 $self->{output}->output_add(short_msg => 'proxy usage is ok');
110
111 $self->{proxy} = {
112 global => {
113 connection => {
114 con_current => $result->{con_current},
115 con_psec => $result->{con_psec}
116 },
117 service => { services_num => $result->{services_num} }
118 }
119 };
120 }
121
122 1;
123
124 __END__
125
126 =head1 MODE
127
128 Check proxy.
129
130 =over 8
131
132 =item B<--filter-counters>
133
134 Only display some counters (regexp can be used).
135 Example: --filter-counters='connections'
136
137 =item B<--warning-*> B<--critical-*>
138
139 Thresholds.
140 Can be: 'connections', 'connections-average', 'services'.
141
142 =back
143
144 =cut