Debian Codegraph @

src/apps/antivirus/mcafee/webgateway/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 apps::antivirus::mcafee::webgateway::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, cb_prefix_output => 'prefix_connection_output' }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'legitimate', nlabel => 'connections.legitimate.persecond', set => {
38 key_values => [ { name => 'stConnectionsLegitimate', per_second => 1 } ],
39 output_template => 'Legitimate: %d',
40 perfdatas => [
41 { label => 'legitimate_connections', template => '%d', min => 0, unit => 'connections/s' }
42 ]
43 }
44 },
45 { label => 'blocked', nlabel => 'connections.blocked.persecond', set => {
46 key_values => [ { name => 'stConnectionsBlocked', per_second => 1 } ],
47 output_template => 'Blocked: %d',
48 perfdatas => [
49 { label => 'blocked_connections', template => '%d', min => 0, unit => 'connections/s' }
50 ]
51 }
52 },
53 { label => 'blocked-by-am', nlabel => 'connections.antimalware.blocked.persecond', set => {
54 key_values => [ { name => 'stBlockedByAntiMalware', per_second => 1 } ],
55 output_template => 'Blocked by Anti Malware: %d',
56 perfdatas => [
57 { label => 'blocked_by_am', template => '%d', min => 0, unit => 'connections/s' }
58 ]
59 }
60 },
61 { label => 'blocked-by-mf', nlabel => 'connections.mediafilter.blocked.persecond', set => {
62 key_values => [ { name => 'stBlockedByMediaFilter', per_second => 1 } ],
63 output_template => 'Blocked by Media Filter: %d',
64 perfdatas => [
65 { label => 'blocked_by_mf', template => '%d', min => 0, unit => 'connections/s' }
66 ]
67 }
68 },
69 { label => 'blocked-by-uf', nlabel => 'connections.urlfilter.blocked.persecond', set => {
70 key_values => [ { name => 'stBlockedByURLFilter', per_second => 1 } ],
71 output_template => 'Blocked by URL Filter: %d',
72 perfdatas => [
73 { label => 'blocked_by_uf', template => '%d', min => 0, unit => 'connections/s' }
74 ]
75 }
76 }
77 ];
78 }
79
80 sub prefix_connection_output {
81 my ($self, %options) = @_;
82
83 return 'Connections (per sec) ';
84 }
85
86 sub new {
87 my ($class, %options) = @_;
88 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
89 bless $self, $class;
90
91 $options{options}->add_options(arguments => {
92 });
93
94 return $self;
95 }
96
97 my $oid_stConnectionsLegitimate = '.1.3.6.1.4.1.1230.2.7.2.1.3.0';
98 my $oid_stBlockedByAntiMalware = '.1.3.6.1.4.1.1230.2.7.2.1.4.0';
99 my $oid_stConnectionsBlocked = '.1.3.6.1.4.1.1230.2.7.2.1.5.0';
100 my $oid_stBlockedByMediaFilter = '.1.3.6.1.4.1.1230.2.7.2.1.6.0';
101 my $oid_stBlockedByURLFilter = '.1.3.6.1.4.1.1230.2.7.2.1.7.0';
102
103 sub manage_selection {
104 my ($self, %options) = @_;
105
106 $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
107 (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
108 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
109
110 my $results = $options{snmp}->get_leef(
111 oids => [
112 $oid_stConnectionsLegitimate, $oid_stBlockedByAntiMalware,
113 $oid_stConnectionsBlocked, $oid_stBlockedByMediaFilter,
114 $oid_stBlockedByURLFilter
115 ],
116 nothing_quit => 1
117 );
118
119 $self->{global} = {
120 stConnectionsLegitimate => $results->{$oid_stConnectionsLegitimate},
121 stBlockedByAntiMalware => $results->{$oid_stBlockedByAntiMalware},
122 stConnectionsBlocked => $results->{$oid_stConnectionsBlocked},
123 stBlockedByMediaFilter => $results->{$oid_stBlockedByMediaFilter},
124 stBlockedByURLFilter => $results->{$oid_stBlockedByURLFilter},
125 };
126 }
127
128 1;
129
130 __END__
131
132 =head1 MODE
133
134 Check connections statistics.
135
136 =over 8
137
138 =item B<--filter-counters>
139
140 Only display some counters (regexp can be used).
141 (example: --filter-counters='blocked')
142
143 =item B<--warning-*>
144
145 Warning threshold.
146 Can be: 'legitimate', 'blocked', 'blocked-by-am',
147 'blocked-by-mf', 'blocked-by-uf'.
148
149 =item B<--critical-*>
150
151 Critical threshold.
152 Can be: 'legitimate', 'blocked', 'blocked-by-am',
153 'blocked-by-mf', 'blocked-by-uf'.
154
155 =back
156
157 =cut