Debian Codegraph @

src/network/fortinet/fortiadc/snmp/mode/security.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::fortiadc::snmp::mode::security;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
28
29 sub set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'global', type => 0 }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 {
38 label => 'ddos-status',
39 type => 2,
40 critical_default => '%{status} eq "attacking"',
41 set => {
42 key_values => [ { name => 'status' } ],
43 output_template => 'DDoS status is %s',
44 closure_custom_perfdata => sub { return 0; },
45 closure_custom_threshold_check => \&catalog_status_threshold_ng
46 }
47 }
48 ];
49 }
50
51 sub new {
52 my ($class, %options) = @_;
53 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
54 bless $self, $class;
55
56 $options{options}->add_options(arguments => {});
57
58 return $self;
59 }
60
61 sub manage_selection {
62 my ($self, %options) = @_;
63
64 my $oid_ddos = '.1.3.6.1.4.1.12356.112.7.1.0'; # fadcDDoSAttackStatus
65 my $snmp_result = $options{snmp}->get_leef(
66 oids => [ $oid_ddos ],
67 nothing_quit => 1
68 );
69
70 $self->{global} = {
71 status => $snmp_result->{$oid_ddos} == 1 ? 'attacking' : 'noAttack'
72 };
73 }
74
75 1;
76
77 __END__
78
79 =head1 MODE
80
81 Check security.
82
83 =over 8
84
85 =item B<--warning-ddos-status>
86
87 Define the conditions to match for the status to be WARNING.
88 You can use the following variables: %{status}
89
90 =item B<--critical-ddos-status>
91
92 Define the conditions to match for the status to be CRITICAL (default: '%{status} eq "attacking"').
93 You can use the following variables: %{status}
94
95 =back
96
97 =cut