Debian Codegraph @

src/apps/antivirus/mcafee/webgateway/snmp/mode/ftpstatistics.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::ftpstatistics;
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 => 'traffics', type => 0, cb_prefix_output => 'prefix_traffic_output' }
34 ];
35
36 $self->{maps_counters}->{traffics} = [
37 { label => 'client-to-proxy', nlabel => 'ftp.traffic.client2proxy.bitspersecond', set => {
38 key_values => [ { name => 'stFtpBytesFromClient', per_second => 1 } ],
39 output_template => 'from client to proxy: %s %s/s',
40 output_change_bytes => 2,
41 perfdatas => [
42 { label => 'ftp_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' }
43 ]
44 }
45 },
46 { label => 'server-to-proxy', nlabel => 'ftp.traffic.server2proxy.bitspersecond', set => {
47 key_values => [ { name => 'stFtpBytesFromServer', per_second => 1 } ],
48 output_template => 'from server to proxy: %s %s/s',
49 output_change_bytes => 2,
50 perfdatas => [
51 { label => 'ftp_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' }
52 ]
53 }
54 },
55 { label => 'proxy-to-client', nlabel => 'ftp.traffic.proxy2client.bitspersecond', set => {
56 key_values => [ { name => 'stFtpBytesToClient', per_second => 1 } ],
57 output_template => 'from proxy to client: %s %s/s',
58 output_change_bytes => 2,
59 perfdatas => [
60 { label => 'ftp_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' }
61 ]
62 }
63 },
64 { label => 'proxy-to-server', nlabel => 'ftp.traffic.proxy2server.bitspersecond', set => {
65 key_values => [ { name => 'stFtpBytesToServer', per_second => 1 } ],
66 output_template => 'from proxy to server: %s %s/s',
67 output_change_bytes => 2,
68 perfdatas => [
69 { label => 'ftp_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' }
70 ]
71 }
72 }
73 ];
74 }
75
76 sub prefix_traffic_output {
77 my ($self, %options) = @_;
78
79 return "FTP Traffic ";
80 }
81
82 sub new {
83 my ($class, %options) = @_;
84 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
85 bless $self, $class;
86
87 $options{options}->add_options(arguments => {
88 });
89
90 return $self;
91 }
92
93 my $oid_stFtpBytesFromClient = '.1.3.6.1.4.1.1230.2.7.2.4.2.0';
94 my $oid_stFtpBytesFromServer = '.1.3.6.1.4.1.1230.2.7.2.4.3.0';
95 my $oid_stFtpBytesToClient = '.1.3.6.1.4.1.1230.2.7.2.4.4.0';
96 my $oid_stFtpBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.4.5.0';
97
98 sub manage_selection {
99 my ($self, %options) = @_;
100
101 $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
102 (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
103 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
104
105 my $results = $options{snmp}->get_leef(
106 oids => [
107 $oid_stFtpBytesFromClient, $oid_stFtpBytesFromServer,
108 $oid_stFtpBytesToClient, $oid_stFtpBytesToServer
109 ],
110 nothing_quit => 1
111 );
112
113 $self->{traffics} = {
114 stFtpBytesFromClient => $results->{$oid_stFtpBytesFromClient} * 8,
115 stFtpBytesFromServer => $results->{$oid_stFtpBytesFromServer} * 8,
116 stFtpBytesToClient => $results->{$oid_stFtpBytesToClient} * 8,
117 stFtpBytesToServer => $results->{$oid_stFtpBytesToServer} * 8,
118 };
119 }
120
121 1;
122
123 __END__
124
125 =head1 MODE
126
127 Check FTP statistics.
128
129 =over 8
130
131 =item B<--filter-counters>
132
133 Only display some counters (regexp can be used).
134 (example: --filter-counters='^proxy')
135
136 =item B<--warning-*>
137
138 Warning threshold.
139 Can be: 'client-to-proxy', 'server-to-proxy',
140 'proxy-to-client', 'proxy-to-server'.
141
142 =item B<--critical-*>
143
144 Critical threshold.
145 Can be: 'client-to-proxy', 'server-to-proxy',
146 'proxy-to-client', 'proxy-to-server'.
147
148 =back
149
150 =cut