Debian Codegraph @

src/centreon/common/fortinet/fortigate/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::fortinet::fortigate::snmp::mode::sessions;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub prefix_average_output {
29 my ($self, %options) = @_;
30
31 return 'Average session setup rate: ';
32 }
33
34 sub set_counters {
35 my ($self, %options) = @_;
36
37 $self->{maps_counters_type} = [
38 { name => 'global', type => 0 },
39 { name => 'average', type => 0, cb_prefix_output => 'prefix_average_output' },
40 ];
41
42 $self->{maps_counters}->{global} = [
43 { label => 'active', nlabel => 'sessions.active.count', set => {
44 key_values => [ { name => 'active' } ],
45 output_template => 'Current active sessions: %d',
46 perfdatas => [
47 { label => 'sessions', template => '%d', min => 0 }
48 ]
49 }
50 }
51 ];
52
53 $self->{maps_counters}->{average} = [
54 { label => 'setup-1min', nlabel => 'sessions.setup.1min.count', set => {
55 key_values => [ { name => 'setup_1min' } ],
56 output_template => '%d (1min)',
57 perfdatas => [
58 { label => 'session_avg_setup1', template => '%d', min => 0 }
59 ]
60 }
61 },
62 { label => 'setup-10min', nlabel => 'sessions.setup.10min.count', set => {
63 key_values => [ { name => 'setup_10min' } ],
64 output_template => '%d (10min)',
65 perfdatas => [
66 { label => 'session_avg_setup10', template => '%d', min => 0 }
67 ]
68 }
69 },
70 { label => 'setup-30min', nlabel => 'sessions.setup.30min.count', set => {
71 key_values => [ { name => 'setup_30min' } ],
72 output_template => '%d (30min)',
73 perfdatas => [
74 { label => 'session_avg_setup30', template => '%d', min => 0 }
75 ]
76 }
77 },
78 { label => 'setup-60min', nlabel => 'sessions.setup.60min.count', set => {
79 key_values => [ { name => 'setup_60min' } ],
80 output_template => '%d (60min)',
81 perfdatas => [
82 { label => 'session_avg_setup60', template => '%d', min => 0 }
83 ]
84 }
85 },
86 ];
87 }
88
89 sub new {
90 my ($class, %options) = @_;
91 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
92 bless $self, $class;
93
94 $options{options}->add_options(arguments => {
95 });
96
97 return $self;
98 }
99
100 sub manage_selection {
101 my ($self, %options) = @_;
102
103 my $oid_fgSysSesCount = '.1.3.6.1.4.1.12356.101.4.1.8.0';
104 my $oid_fgSysSesRate1 = '.1.3.6.1.4.1.12356.101.4.1.11.0';
105 my $oid_fgSysSesRate10 = '.1.3.6.1.4.1.12356.101.4.1.12.0';
106 my $oid_fgSysSesRate30 = '.1.3.6.1.4.1.12356.101.4.1.13.0';
107 my $oid_fgSysSesRate60 = '.1.3.6.1.4.1.12356.101.4.1.14.0';
108 my $result = $options{snmp}->get_leef(
109 oids => [
110 $oid_fgSysSesCount, $oid_fgSysSesRate1,
111 $oid_fgSysSesRate10, $oid_fgSysSesRate30, $oid_fgSysSesRate60
112 ],
113 nothing_quit => 1
114 );
115
116 $self->{global} = { active => $result->{$oid_fgSysSesCount} };
117 $self->{average} = {
118 setup_1min => $result->{$oid_fgSysSesRate1},
119 setup_10min => $result->{$oid_fgSysSesRate10},
120 setup_30min => $result->{$oid_fgSysSesRate30},
121 setup_60min => $result->{$oid_fgSysSesRate60}
122 };
123 }
124
125 1;
126
127 __END__
128
129 =head1 MODE
130
131 Check sessions (FORTINET-FORTIGATE-MIB).
132
133 =over 8
134
135 =item B<--warning-*> B<--critical-*>
136
137 Thresholds.
138 Can be: 'active', 'setup-1min', 'setup-10min', 'setup-30min', 'setup-60min'.
139
140 =back
141
142 =cut