This commit is contained in:
qgarnier 2021-02-19 11:24:25 +01:00 committed by GitHub
parent f150b96265
commit d3ac05e6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 176 additions and 67 deletions

View File

@ -24,7 +24,6 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -71,10 +70,10 @@ my $oid_stConnectedSockets = '.1.3.6.1.4.1.1230.2.7.2.5.3.0';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $results = $options{snmp}->get_leef(oids => [ $oid_stClientCount, $oid_stConnectedSockets ], my $results = $options{snmp}->get_leef(
nothing_quit => 1); oids => [ $oid_stClientCount, $oid_stConnectedSockets ],
nothing_quit => 1
$self->{global} = {}; );
$self->{global} = { $self->{global} = {
stClientCount => $results->{$oid_stClientCount}, stClientCount => $results->{$oid_stClientCount},

View File

@ -80,7 +80,7 @@ sub set_counters {
sub prefix_connection_output { sub prefix_connection_output {
my ($self, %options) = @_; my ($self, %options) = @_;
return "Connections (per sec) "; return 'Connections (per sec) ';
} }
sub new { sub new {
@ -103,16 +103,18 @@ my $oid_stBlockedByURLFilter = '.1.3.6.1.4.1.1230.2.7.2.1.7.0';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{cache_name} = "mcafee_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(oids => [ $oid_stConnectionsLegitimate, $oid_stBlockedByAntiMalware, my $results = $options{snmp}->get_leef(
$oid_stConnectionsBlocked, $oid_stBlockedByMediaFilter, oids => [
$oid_stBlockedByURLFilter ], $oid_stConnectionsLegitimate, $oid_stBlockedByAntiMalware,
nothing_quit => 1); $oid_stConnectionsBlocked, $oid_stBlockedByMediaFilter,
$oid_stBlockedByURLFilter
$self->{global} = {}; ],
nothing_quit => 1
);
$self->{global} = { $self->{global} = {
stConnectionsLegitimate => $results->{$oid_stConnectionsLegitimate}, stConnectionsLegitimate => $results->{$oid_stConnectionsLegitimate},

View File

@ -88,21 +88,18 @@ my $oid_stCategoriesEntry = '.1.3.6.1.4.1.1230.2.7.2.1.10.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{cache_name} = "mcafee_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(oids => [ $oid_stMalwareDetected ], nothing_quit => 1); my $results = $options{snmp}->get_leef(oids => [ $oid_stMalwareDetected ], nothing_quit => 1);
my $results2 = $options{snmp}->get_table(oid => $oid_stCategoriesEntry, nothing_quit => 1); my $results2 = $options{snmp}->get_table(oid => $oid_stCategoriesEntry, nothing_quit => 1);
$self->{global} = {};
$self->{categories} = {};
$self->{global} = { $self->{global} = {
stMalwareDetected => $results->{$oid_stMalwareDetected}, stMalwareDetected => $results->{$oid_stMalwareDetected},
}; };
$self->{categories} = {};
foreach my $oid (keys %{$results2}) { foreach my $oid (keys %{$results2}) {
next if ($oid !~ /^$mapping->{stCategoryName}->{oid}\.(\d+)/); next if ($oid !~ /^$mapping->{stCategoryName}->{oid}\.(\d+)/);
my $instance = $1; my $instance = $1;
@ -114,9 +111,9 @@ sub manage_selection {
next; next;
} }
$self->{categories}->{$result->{stCategoryName}} = { $self->{categories}->{ $result->{stCategoryName} } = {
stCategoryName => $result->{stCategoryName}, stCategoryName => $result->{stCategoryName},
stCategoryCount => $result->{stCategoryCount}, stCategoryCount => $result->{stCategoryCount}
} }
} }

View File

@ -98,15 +98,17 @@ my $oid_stFtpBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.4.5.0';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{cache_name} = "mcafee_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(oids => [ $oid_stFtpBytesFromClient, $oid_stFtpBytesFromServer, my $results = $options{snmp}->get_leef(
$oid_stFtpBytesToClient, $oid_stFtpBytesToServer ], oids => [
nothing_quit => 1); $oid_stFtpBytesFromClient, $oid_stFtpBytesFromServer,
$oid_stFtpBytesToClient, $oid_stFtpBytesToServer
$self->{traffics} = {}; ],
nothing_quit => 1
);
$self->{traffics} = { $self->{traffics} = {
stFtpBytesFromClient => $results->{$oid_stFtpBytesFromClient} * 8, stFtpBytesFromClient => $results->{$oid_stFtpBytesFromClient} * 8,

View File

@ -110,26 +110,27 @@ my $oid_stHttpsBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.3.6.0';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{cache_name} = "mcafee_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(oids => [ $oid_stHttpsRequests, $oid_stHttpsBytesFromClient, my $results = $options{snmp}->get_leef(
$oid_stHttpsBytesFromServer, $oid_stHttpsBytesToClient, oids => [
$oid_stHttpsBytesToServer ], $oid_stHttpsRequests, $oid_stHttpsBytesFromClient,
nothing_quit => 1); $oid_stHttpsBytesFromServer, $oid_stHttpsBytesToClient,
$oid_stHttpsBytesToServer
$self->{global} = {}; ],
$self->{traffics} = {}; nothing_quit => 1
);
$self->{global} = { $self->{global} = {
stHttpsRequests => $results->{$oid_stHttpsRequests}, stHttpsRequests => $results->{$oid_stHttpsRequests}
}; };
$self->{traffics} = { $self->{traffics} = {
stHttpsBytesFromClient => $results->{$oid_stHttpsBytesFromClient} * 8, stHttpsBytesFromClient => $results->{$oid_stHttpsBytesFromClient} * 8,
stHttpsBytesFromServer => $results->{$oid_stHttpsBytesFromServer} * 8, stHttpsBytesFromServer => $results->{$oid_stHttpsBytesFromServer} * 8,
stHttpsBytesToClient => $results->{$oid_stHttpsBytesToClient} * 8, stHttpsBytesToClient => $results->{$oid_stHttpsBytesToClient} * 8,
stHttpsBytesToServer => $results->{$oid_stHttpsBytesToServer} * 8, stHttpsBytesToServer => $results->{$oid_stHttpsBytesToServer} * 8
}; };
} }

View File

@ -111,26 +111,27 @@ my $oid_stHttpBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.2.6.0';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{cache_name} = "mcafee_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . $self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(oids => [ $oid_stHttpRequests, $oid_stHttpBytesFromClient, my $results = $options{snmp}->get_leef(
$oid_stHttpBytesFromServer, $oid_stHttpBytesToClient, oids => [
$oid_stHttpBytesToServer ], $oid_stHttpRequests, $oid_stHttpBytesFromClient,
nothing_quit => 1); $oid_stHttpBytesFromServer, $oid_stHttpBytesToClient,
$oid_stHttpBytesToServer
$self->{global} = {}; ],
$self->{traffics} = {}; nothing_quit => 1
);
$self->{global} = { $self->{global} = {
stHttpRequests => $results->{$oid_stHttpRequests}, stHttpRequests => $results->{$oid_stHttpRequests}
}; };
$self->{traffics} = { $self->{traffics} = {
stHttpBytesFromClient => $results->{$oid_stHttpBytesFromClient} * 8, stHttpBytesFromClient => $results->{$oid_stHttpBytesFromClient} * 8,
stHttpBytesFromServer => $results->{$oid_stHttpBytesFromServer} * 8, stHttpBytesFromServer => $results->{$oid_stHttpBytesFromServer} * 8,
stHttpBytesToClient => $results->{$oid_stHttpBytesToClient} * 8, stHttpBytesToClient => $results->{$oid_stHttpBytesToClient} * 8,
stHttpBytesToServer => $results->{$oid_stHttpBytesToServer} * 8, stHttpBytesToServer => $results->{$oid_stHttpBytesToServer} * 8
}; };
} }

View File

@ -0,0 +1,104 @@
#
# Copyright 2021 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::antivirus::mcafee::webgateway::snmp::mode::system;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{ label => 'cpu-utilization', nlabel => 'system.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_util' } ],
output_template => 'cpu usage: %.2f%%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100 }
]
}
},
{ label => 'dns-resolve-time', nlabel => 'system.dns.resolve.time.milliseconds', set => {
key_values => [ { name => 'dns_time' } ],
output_template => 'time to resolve dns: %sms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $oid_stCPULoad = '.1.3.6.1.4.1.1230.2.7.2.5.1.0';
my $oid_stResolveHostViaDNS = '.1.3.6.1.4.1.1230.2.7.2.5.6.0';
sub manage_selection {
my ($self, %options) = @_;
my $results = $options{snmp}->get_leef(
oids => [ $oid_stCPULoad, $oid_stResolveHostViaDNS ],
nothing_quit => 1
);
$self->{global} = {
cpu_util => $results->{$oid_stCPULoad},
dns_time => $results->{$oid_stResolveHostViaDNS}
};
}
1;
__END__
=head1 MODE
Check system.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='cpu')
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'cpu-utilization', 'dns-resolve-time'.
=back
=cut

View File

@ -41,10 +41,13 @@ sub custom_version_calc {
sub custom_version_threshold { sub custom_version_threshold {
my ($self, %options) = @_; my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{since}, return $self->{perfdata}->threshold_check(
threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, value => $self->{result_values}->{since},
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); threshold => [
return $exit; { label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' }
]
);
} }
sub custom_version_output { sub custom_version_output {
@ -72,7 +75,7 @@ sub set_counters {
closure_custom_calc_extra_options => { label_ref => 'pMFEDATVersion', output_ref => 'DAT Version' }, closure_custom_calc_extra_options => { label_ref => 'pMFEDATVersion', output_ref => 'DAT Version' },
closure_custom_output => $self->can('custom_version_output'), closure_custom_output => $self->can('custom_version_output'),
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_version_threshold'), closure_custom_threshold_check => $self->can('custom_version_threshold')
} }
}, },
{ label => 'tsdb-version', set => { { label => 'tsdb-version', set => {
@ -81,7 +84,7 @@ sub set_counters {
closure_custom_calc_extra_options => { label_ref => 'pTSDBVersion', output_ref => 'TrustedSource Database Version' }, closure_custom_calc_extra_options => { label_ref => 'pTSDBVersion', output_ref => 'TrustedSource Database Version' },
closure_custom_output => $self->can('custom_version_output'), closure_custom_output => $self->can('custom_version_output'),
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_version_threshold'), closure_custom_threshold_check => $self->can('custom_version_threshold')
} }
}, },
{ label => 'proactive-version', set => { { label => 'proactive-version', set => {
@ -90,19 +93,12 @@ sub set_counters {
closure_custom_calc_extra_options => { label_ref => 'pAMProactiveVersion', output_ref => 'ProActive Database Version' }, closure_custom_calc_extra_options => { label_ref => 'pAMProactiveVersion', output_ref => 'ProActive Database Version' },
closure_custom_output => $self->can('custom_version_output'), closure_custom_output => $self->can('custom_version_output'),
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_version_threshold'), closure_custom_threshold_check => $self->can('custom_version_threshold')
} }
} }
]; ];
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->{cache}->check_options(%options);
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -115,6 +111,13 @@ sub new {
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->{cache}->check_options(%options);
}
my $oid_pMFEDATVersion = '.1.3.6.1.4.1.1230.2.7.1.20.4.0'; my $oid_pMFEDATVersion = '.1.3.6.1.4.1.1230.2.7.1.20.4.0';
my $oid_pAMProactiveVersion = '.1.3.6.1.4.1.1230.2.7.1.20.5.0'; my $oid_pAMProactiveVersion = '.1.3.6.1.4.1.1230.2.7.1.20.5.0';
my $oid_pTSDBVersion = '.1.3.6.1.4.1.1230.2.7.1.20.6.0'; my $oid_pTSDBVersion = '.1.3.6.1.4.1.1230.2.7.1.20.6.0';
@ -122,19 +125,18 @@ my $oid_pTSDBVersion = '.1.3.6.1.4.1.1230.2.7.1.20.6.0';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{new_datas} = {}; $self->{cache}->read(statefile => 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
$self->{cache}->read(statefile => "mcafee_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'))); (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')));
my $results = $options{snmp}->get_leef(oids => [ $oid_pMFEDATVersion, $oid_pAMProactiveVersion, $oid_pTSDBVersion ], my $results = $options{snmp}->get_leef(
nothing_quit => 1); oids => [ $oid_pMFEDATVersion, $oid_pAMProactiveVersion, $oid_pTSDBVersion ],
nothing_quit => 1
$self->{global} = {}; );
$self->{new_datas} = { $self->{new_datas} = {
pMFEDATVersion => $results->{$oid_pMFEDATVersion}, pMFEDATVersion => $results->{$oid_pMFEDATVersion},
pAMProactiveVersion => $results->{$oid_pAMProactiveVersion}, pAMProactiveVersion => $results->{$oid_pAMProactiveVersion},
pTSDBVersion => $results->{$oid_pTSDBVersion}, pTSDBVersion => $results->{$oid_pTSDBVersion}
}; };
foreach my $version (('pMFEDATVersion', 'pAMProactiveVersion', 'pTSDBVersion')) { foreach my $version (('pMFEDATVersion', 'pAMProactiveVersion', 'pTSDBVersion')) {

View File

@ -38,6 +38,7 @@ sub new {
'ftp-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::ftpstatistics', 'ftp-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::ftpstatistics',
'http-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpstatistics', 'http-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpstatistics',
'https-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpsstatistics', 'https-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpsstatistics',
'system' => 'apps::antivirus::mcafee::webgateway::snmp::mode::system',
'versions' => 'apps::antivirus::mcafee::webgateway::snmp::mode::versions', 'versions' => 'apps::antivirus::mcafee::webgateway::snmp::mode::versions',
}; };