| 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::httpsstatistics; |
| 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 }, |
| 34 |
{ name => 'traffics', type => 0, cb_prefix_output => 'prefix_traffic_output' } |
| 35 |
]; |
| 36 |
|
| 37 |
$self->{maps_counters}->{global} = [ |
| 38 |
{ label => 'requests', nlabel => 'https.requests.persecond', set => { |
| 39 |
key_values => [ { name => 'stHttpsRequests', per_second => 1 } ], |
| 40 |
output_template => 'HTTPS Requests (per sec): %d', |
| 41 |
perfdatas => [ |
| 42 |
{ label => 'https_requests', template => '%d', min => 0, unit => 'requests/s' } |
| 43 |
] |
| 44 |
} |
| 45 |
} |
| 46 |
]; |
| 47 |
$self->{maps_counters}->{traffics} = [ |
| 48 |
{ label => 'client-to-proxy', nlabel => 'https.traffic.client2proxy.bitspersecond', set => { |
| 49 |
key_values => [ { name => 'stHttpsBytesFromClient', per_second => 1 } ], |
| 50 |
output_template => 'from client to proxy: %s %s/s', |
| 51 |
output_change_bytes => 2, |
| 52 |
perfdatas => [ |
| 53 |
{ label => 'https_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' } |
| 54 |
] |
| 55 |
} |
| 56 |
}, |
| 57 |
{ label => 'server-to-proxy', nlabel => 'https.traffic.server2proxy.bitspersecond', set => { |
| 58 |
key_values => [ { name => 'stHttpsBytesFromServer', per_second => 1 } ], |
| 59 |
output_template => 'from server to proxy: %s %s/s', |
| 60 |
output_change_bytes => 2, |
| 61 |
perfdatas => [ |
| 62 |
{ label => 'https_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' } |
| 63 |
] |
| 64 |
} |
| 65 |
}, |
| 66 |
{ label => 'proxy-to-client', nlabel => 'https.traffic.proxy2client.bitspersecond', set => { |
| 67 |
key_values => [ { name => 'stHttpsBytesToClient', per_second => 1 } ], |
| 68 |
output_template => 'from proxy to client: %s %s/s', |
| 69 |
output_change_bytes => 2, |
| 70 |
perfdatas => [ |
| 71 |
{ label => 'https_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' } |
| 72 |
] |
| 73 |
} |
| 74 |
}, |
| 75 |
{ label => 'proxy-to-server', nlabel => 'https.traffic.proxy2server.bitspersecond', set => { |
| 76 |
key_values => [ { name => 'stHttpsBytesToServer', per_second => 1 } ], |
| 77 |
output_template => 'from proxy to server: %s %s/s', |
| 78 |
output_change_bytes => 2, |
| 79 |
perfdatas => [ |
| 80 |
{ label => 'https_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' } |
| 81 |
] |
| 82 |
} |
| 83 |
} |
| 84 |
]; |
| 85 |
} |
| 86 |
|
| 87 |
sub prefix_traffic_output { |
| 88 |
my ($self, %options) = @_; |
| 89 |
|
| 90 |
return "HTTPS Traffic "; |
| 91 |
} |
| 92 |
|
| 93 |
sub new { |
| 94 |
my ($class, %options) = @_; |
| 95 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); |
| 96 |
bless $self, $class; |
| 97 |
|
| 98 |
$options{options}->add_options(arguments => { |
| 99 |
}); |
| 100 |
|
| 101 |
return $self; |
| 102 |
} |
| 103 |
|
| 104 |
my $oid_stHttpsRequests = '.1.3.6.1.4.1.1230.2.7.2.3.1.0'; |
| 105 |
my $oid_stHttpsBytesFromClient = '.1.3.6.1.4.1.1230.2.7.2.3.3.0'; |
| 106 |
my $oid_stHttpsBytesFromServer = '.1.3.6.1.4.1.1230.2.7.2.3.4.0'; |
| 107 |
my $oid_stHttpsBytesToClient = '.1.3.6.1.4.1.1230.2.7.2.3.5.0'; |
| 108 |
my $oid_stHttpsBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.3.6.0'; |
| 109 |
|
| 110 |
sub manage_selection { |
| 111 |
my ($self, %options) = @_; |
| 112 |
|
| 113 |
$self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . |
| 114 |
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . |
| 115 |
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); |
| 116 |
|
| 117 |
my $results = $options{snmp}->get_leef( |
| 118 |
oids => [ |
| 119 |
$oid_stHttpsRequests, $oid_stHttpsBytesFromClient, |
| 120 |
$oid_stHttpsBytesFromServer, $oid_stHttpsBytesToClient, |
| 121 |
$oid_stHttpsBytesToServer |
| 122 |
], |
| 123 |
nothing_quit => 1 |
| 124 |
); |
| 125 |
|
| 126 |
$self->{global} = { |
| 127 |
stHttpsRequests => $results->{$oid_stHttpsRequests} |
| 128 |
}; |
| 129 |
$self->{traffics} = { |
| 130 |
stHttpsBytesFromClient => $results->{$oid_stHttpsBytesFromClient} * 8, |
| 131 |
stHttpsBytesFromServer => $results->{$oid_stHttpsBytesFromServer} * 8, |
| 132 |
stHttpsBytesToClient => $results->{$oid_stHttpsBytesToClient} * 8, |
| 133 |
stHttpsBytesToServer => $results->{$oid_stHttpsBytesToServer} * 8 |
| 134 |
}; |
| 135 |
} |
| 136 |
|
| 137 |
1; |
| 138 |
|
| 139 |
__END__ |
| 140 |
|
| 141 |
=head1 MODE |
| 142 |
|
| 143 |
Check HTTPS statistics. |
| 144 |
|
| 145 |
=over 8 |
| 146 |
|
| 147 |
=item B<--filter-counters> |
| 148 |
|
| 149 |
Only display some counters (regexp can be used). |
| 150 |
(example: --filter-counters='^proxy') |
| 151 |
|
| 152 |
=item B<--warning-*> |
| 153 |
|
| 154 |
Warning threshold. |
| 155 |
Can be: 'request', 'client-to-proxy', 'server-to-proxy', |
| 156 |
'proxy-to-client', 'proxy-to-server'. |
| 157 |
|
| 158 |
=item B<--critical-*> |
| 159 |
|
| 160 |
Critical threshold. |
| 161 |
Can be: 'request', 'client-to-proxy', 'server-to-proxy', |
| 162 |
'proxy-to-client', 'proxy-to-server'. |
| 163 |
|
| 164 |
=back |
| 165 |
|
| 166 |
=cut |