Cisco firepower (#2330)
This commit is contained in:
parent
fce6f484e5
commit
008a73c3af
|
@ -0,0 +1,276 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fmc::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use centreon::plugins::statefile;
|
||||
use JSON::XS;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'api-username:s' => { name => 'api_username' },
|
||||
'api-password:s' => { name => 'api_password' },
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'port:s' => { name => 'port' },
|
||||
'proto:s' => { name => 'proto' },
|
||||
'timeout:s' => { name => 'timeout' },
|
||||
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
||||
'warning-http-status:s' => { name => 'warning_http_status' },
|
||||
'critical-http-status:s' => { name => 'critical_http_status' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{http} = centreon::plugins::http->new(%options);
|
||||
$self->{cache} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
|
||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : '';
|
||||
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : '';
|
||||
|
||||
if ($self->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{api_username} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --api-username option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{api_password} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --api-password option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{cache}->check_options(option_results => $self->{option_results});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_hostname {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{hostname};
|
||||
}
|
||||
|
||||
sub get_port {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{port};
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = $self->{hostname};
|
||||
$self->{option_results}->{port} = $self->{port};
|
||||
$self->{option_results}->{proto} = $self->{proto};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8');
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json;charset=UTF-8');
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
}
|
||||
|
||||
sub json_decode {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $decoded;
|
||||
eval {
|
||||
$decoded = JSON::XS->new->utf8->decode($options{content});
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
sub clean_session_token {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $datas = { last_timestamp => time() };
|
||||
$options{statefile}->write(data => $datas);
|
||||
$self->{session_token} = undef;
|
||||
$self->{http}->add_header(key => 'X-auth-access-token', value => undef);
|
||||
}
|
||||
|
||||
sub authenticate {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $has_cache_file = $options{statefile}->read(statefile => 'cisco_firepower_fmc_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username}));
|
||||
my $session_token = $options{statefile}->get(name => 'session_token');
|
||||
|
||||
if ($has_cache_file == 0 || !defined($session_token)) {
|
||||
$self->{http}->request(
|
||||
url_path => '/api/fmc_platform/v1/auth/generatetoken',
|
||||
credentials => 1,
|
||||
basic => 1,
|
||||
username => $self->{api_username},
|
||||
password => $self->{api_password},
|
||||
warning_status => '',
|
||||
unknown_status => '',
|
||||
critical_status => ''
|
||||
);
|
||||
if ($self->{http}->get_code() != 200) {
|
||||
$self->{output}->add_option_msg(short_msg => "login error [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$session_token = $self->{http}->get_header(name => 'X-auth-access-token');
|
||||
if (!defined($session_token)) {
|
||||
$self->{output}->add_option_msg(short_msg => 'error retrieving session_token');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $datas = { last_timestamp => time(), session_token => $session_token };
|
||||
$options{statefile}->write(data => $datas);
|
||||
}
|
||||
|
||||
$self->{session_token} = $session_token;
|
||||
$self->{http}->add_header(key => 'X-auth-access-token', value => $self->{session_token});
|
||||
}
|
||||
|
||||
sub request_api {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings();
|
||||
if (!defined($self->{session_token})) {
|
||||
$self->authenticate(statefile => $self->{cache});
|
||||
}
|
||||
|
||||
my ($content) = $self->{http}->request(
|
||||
url_path => '/api/fmc_platform/v1' . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
unknown_status => '',
|
||||
warning_status => '',
|
||||
critical_status => ''
|
||||
);
|
||||
|
||||
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
|
||||
$self->clean_session_token(statefile => $self->{cache});
|
||||
$self->authenticate(statefile => $self->{cache});
|
||||
($content) = $self->{http}->request(
|
||||
url_path => '/api/fmc_platform/v1' . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
unknown_status => $self->{unknown_http_status},
|
||||
warning_status => $self->{warning_http_status},
|
||||
critical_status => $self->{critical_http_status}
|
||||
);
|
||||
}
|
||||
|
||||
my $decoded = $self->json_decode(content => $content);
|
||||
if (!defined($decoded)) {
|
||||
$self->{output}->add_option_msg(short_msg => 'error while retrieving data (add --debug option for detailed message)');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Firepower Management Center Rest API
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
Firepower Management Center Rest API
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Set hostname.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Port used (Default: 443)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'https')
|
||||
|
||||
=item B<--api-username>
|
||||
|
||||
Set username.
|
||||
|
||||
=item B<--api-password>
|
||||
|
||||
Set password.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout in seconds (Default: 10).
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,169 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fmc::restapi::mode::devices;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_device_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'status: ' . $self->{result_values}->{status};
|
||||
}
|
||||
|
||||
sub domain_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking domain '" . $options{instance_value}->{display} . "'";
|
||||
}
|
||||
|
||||
sub prefix_domain_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Domain '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_device_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "device '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Devices ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'domains', type => 3, cb_prefix_output => 'prefix_domain_output', cb_long_output => 'domain_long_output', indent_long_output => ' ', message_multiple => 'All domains are ok',
|
||||
group => [
|
||||
{ name => 'devices', display_long => 1, cb_prefix_output => 'prefix_device_output', message_multiple => 'All devices are ok', type => 1, skipped_code => { -10 => 1 } },
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'devices-total', nlabel => 'devices.total.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'devices_total' } ],
|
||||
output_template => 'total: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
foreach (('green', 'black', 'blue', 'red', 'yellow')) {
|
||||
push @{$self->{maps_counters}->{global}},
|
||||
{ label => 'devices-status-' . $_, nlabel => 'devices.status. ' . $_ . '.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'devices_' . $_ }, { name => 'devices_total' } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, max => 'devices_total' }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$self->{maps_counters}->{devices} = [
|
||||
{
|
||||
label => 'device-status',
|
||||
type => 2,
|
||||
warning_default => '%{status} =~ /yellow/i',
|
||||
critical_default => '%{status} =~ /red|black/i',
|
||||
set => {
|
||||
key_values => [ { name => 'status' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_device_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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 => {
|
||||
'filter-domain-name:s' => { name => 'filter_domain_name' },
|
||||
'filter-device-name:s' => { name => 'filter_device_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $domains = $options{custom}->request_api(
|
||||
endpoint => '/info/domain',
|
||||
);
|
||||
|
||||
$self->{global} = {
|
||||
devices_total => 0, devices_black => 0,
|
||||
devices_red => 0, devices_yellow => 0,
|
||||
devices_green => 0, devices_blue => 0
|
||||
};
|
||||
$self->{devices} = {};
|
||||
|
||||
if (defined($self->{option_results}->{filter_device_name}) && $self->{option_results}->{filter_device_name} ne '' &&
|
||||
$_->{name} !~ /$self->{option_results}->{filter_device_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check devices.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-domain-name>
|
||||
|
||||
Filter devices by domain name (Can be a regexp).
|
||||
|
||||
=item B<--filter-device-name>
|
||||
|
||||
Filter devices by name (Can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'black', 'red', 'orange'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fmc::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ( $class, %options ) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
$self->{modes} = {
|
||||
'devices' => 'network::cisco::firepower::fmc::restapi::mode::devices',
|
||||
'discovery' => 'network::cisco::firepower::fmc::restapi::mode::discovery'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{api} = 'network::cisco::firepower::fmc::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco Firepower Management Center using Rest API.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,113 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::chassis;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability);
|
||||
|
||||
my $mapping = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.21.1.2' }, # cfprEquipmentChassisDn
|
||||
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.20.21.1.31', map => $map_operability } # cfprEquipmentChassisOperability
|
||||
};
|
||||
my $mapping_stats = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.26.1.2' }, # cfprEquipmentChassisStatsDn
|
||||
input_power => { oid => '.1.3.6.1.4.1.9.9.826.1.20.26.1.5' }, # cfprEquipmentChassisStatsInputPowerAvg
|
||||
output_power => { oid => '.1.3.6.1.4.1.9.9.826.1.20.26.1.10' } # cfprEquipmentChassisStatsOutputPowerAvg
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats));
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking chassis");
|
||||
$self->{components}->{chassis} = { name => 'chassis', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'chassis'));
|
||||
|
||||
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) };
|
||||
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) };
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
|
||||
|
||||
next if ($self->check_filter(section => 'chassis', instance => $result->{dn}));
|
||||
$self->{components}->{chassis}->{total}++;
|
||||
|
||||
my $result_stats = $self->compare_dn(
|
||||
regexp => "^$result->{dn}/",
|
||||
lookup => 'dn',
|
||||
results => $results_stats,
|
||||
mapping => $mapping_stats
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"chassis '%s' status is '%s' [input power: %s W, output power: %s W].",
|
||||
$result->{dn},
|
||||
$result->{operability},
|
||||
$result_stats->{input_power},
|
||||
$result_stats->{output_power},
|
||||
)
|
||||
);
|
||||
$exit = $self->get_severity(label => 'operability', section => 'chassis', instance => $result->{dn}, value => $result->{operability});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"chassis '%s' status is '%s'",
|
||||
$result->{dn},
|
||||
$result->{operability}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach (('input', 'output')) {
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassis.' . $_ . 'power', instance => $result->{dn}, value => $result_stats->{$_ . '_power'});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"chassis '%s' %s power is %s W",
|
||||
$result->{dn},
|
||||
$result_stats->{$_ . '_power'}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.chassis.' . $_ . '.power.watt',
|
||||
unit => 'W',
|
||||
instances => $result->{dn},
|
||||
value => $result_stats->{$_ . '_power'},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,111 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::cpuunit;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability);
|
||||
|
||||
my $mapping = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.66.9.1.2' }, # cfprProcessorUnitDn
|
||||
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.66.9.1.12', map => $map_operability } # cfprProcessorUnitOperability
|
||||
};
|
||||
my $mapping_stats = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.66.2.1.2' }, # cfprProcessorEnvStatsDn
|
||||
temperature => { oid => '.1.3.6.1.4.1.9.9.826.1.66.2.1.11' } # cfprProcessorEnvStatsTemperatureAvg
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats));
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => 'checking cpu units');
|
||||
$self->{components}->{cpuunit} = { name => 'cpu units', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'cpuunit'));
|
||||
|
||||
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) };
|
||||
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) };
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
|
||||
|
||||
next if ($self->check_filter(section => 'cpuunit', instance => $result->{dn}));
|
||||
$self->{components}->{cpuunit}->{total}++;
|
||||
|
||||
my $result_stats = $self->compare_dn(
|
||||
regexp => "^$result->{dn}/",
|
||||
lookup => 'dn',
|
||||
results => $results_stats,
|
||||
mapping => $mapping_stats
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"cpu unit '%s' status is '%s' [temperature: %s C].",
|
||||
$result->{dn},
|
||||
$result->{operability},
|
||||
defined($result_stats->{temperature}) ? $result_stats->{temperature} : '-'
|
||||
)
|
||||
);
|
||||
$exit = $self->get_severity(label => 'operability', section => 'cpuunit', instance => $result->{dn}, value => $result->{operability});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"cpu unit '%s' status is '%s'",
|
||||
$result->{dn},
|
||||
$result->{operability}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
next if (!defined($result_stats->{temperature}));
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'cpuunit.temperature', instance => $result->{dn}, value => $result_stats->{temperature});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"cpu unit '%s' temperature is %s C",
|
||||
$result->{dn},
|
||||
$result_stats->{temperature}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.cpuunit.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $result->{dn},
|
||||
value => $result_stats->{temperature},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability);
|
||||
|
||||
my $mapping = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.34.1.2' }, # cfprEquipmentFanDn
|
||||
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.20.34.1.11', map => $map_operability } # cfprEquipmentFanOperability
|
||||
};
|
||||
my $mapping_stats = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.40.1.2' }, # cfprEquipmentFanStatsDn
|
||||
speed => { oid => '.1.3.6.1.4.1.9.9.826.1.20.40.1.6' } # cfprEquipmentFanStatsSpeedAvg
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats));
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking fans");
|
||||
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) };
|
||||
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) };
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
|
||||
|
||||
next if ($self->check_filter(section => 'fan', instance => $result->{dn}));
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
my $result_stats = $self->compare_dn(
|
||||
regexp => "^$result->{dn}/",
|
||||
lookup => 'dn',
|
||||
results => $results_stats,
|
||||
mapping => $mapping_stats
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fan '%s' status is '%s' [speed: %s RPM].",
|
||||
$result->{dn},
|
||||
$result->{operability},
|
||||
$result_stats->{speed}
|
||||
)
|
||||
);
|
||||
$exit = $self->get_severity(label => 'operability', section => 'fan', instance => $result->{dn}, value => $result->{operability});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"fan '%s' status is '%s'",
|
||||
$result->{dn},
|
||||
$result->{operability}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan.speed', instance => $result->{dn}, value => $result_stats->{speed});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"fan '%s' speed is %s rpm",
|
||||
$result->{dn},
|
||||
$result_stats->{speed}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.fan.speed.rpm',
|
||||
unit => 'rpm',
|
||||
instances => $result->{dn},
|
||||
value => $result_stats->{speed},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::fanmodule;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability);
|
||||
|
||||
my $mapping = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.35.1.2' }, # cfprEquipmentFanModuleDn
|
||||
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.20.35.1.10', map => $map_operability } # cfprEquipmentFanModuleOperability
|
||||
};
|
||||
my $mapping_stats = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.38.1.2' }, # cfprEquipmentFanModuleStatsDn
|
||||
temperature => { oid => '.1.3.6.1.4.1.9.9.826.1.20.38.1.5' } # cfprEquipmentFanModuleStatsAmbientTempAvg
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats));
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking fan modules");
|
||||
$self->{components}->{fanmodule} = { name => 'fan modules', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fanmodule'));
|
||||
|
||||
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) };
|
||||
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) };
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
|
||||
|
||||
next if ($self->check_filter(section => 'fanmodule', instance => $result->{dn}));
|
||||
$self->{components}->{fanmodule}->{total}++;
|
||||
|
||||
my $result_stats = $self->compare_dn(
|
||||
regexp => "^$result->{dn}/",
|
||||
lookup => 'dn',
|
||||
results => $results_stats,
|
||||
mapping => $mapping_stats
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fan module '%s' status is '%s' [temperature: %s C].",
|
||||
$result->{dn},
|
||||
$result->{operability},
|
||||
$result_stats->{temperature}
|
||||
)
|
||||
);
|
||||
$exit = $self->get_severity(label => 'operability', section => 'fanmodule', instance => $result->{dn}, value => $result->{operability});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"fan module '%s' status is '%s'",
|
||||
$result->{dn},
|
||||
$result->{operability}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fanmodule.temperature', instance => $result->{dn}, value => $result_stats->{speed});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"fan module '%s' temperature is %s C",
|
||||
$result->{dn},
|
||||
$result_stats->{temperature}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.fanmodule.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $result->{dn},
|
||||
value => $result_stats->{temperature},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,111 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::memoryunit;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability);
|
||||
|
||||
my $mapping = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.50.11.1.2' }, # cfprMemoryUnitDn
|
||||
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.50.11.1.18', map => $map_operability } # cfprMemoryUnitOperability
|
||||
};
|
||||
my $mapping_stats = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.50.12.1.2' }, # cfprMemoryUnitEnvStatsDn
|
||||
temperature => { oid => '.1.3.6.1.4.1.9.9.826.1.50.12.1.7' } # cfprMemoryUnitEnvStatsTemperatureAvg
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats));
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => 'checking memory units');
|
||||
$self->{components}->{memoryunit} = { name => 'memory units', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'memoryunit'));
|
||||
|
||||
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) };
|
||||
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) };
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
|
||||
|
||||
next if ($self->check_filter(section => 'memoryunit', instance => $result->{dn}));
|
||||
$self->{components}->{memoryunit}->{total}++;
|
||||
|
||||
my $result_stats = $self->compare_dn(
|
||||
regexp => "^$result->{dn}/",
|
||||
lookup => 'dn',
|
||||
results => $results_stats,
|
||||
mapping => $mapping_stats
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"memory unit '%s' status is '%s' [temperature: %s C].",
|
||||
$result->{dn},
|
||||
$result->{operability},
|
||||
defined($result_stats->{temperature}) ? $result_stats->{temperature} : '-'
|
||||
)
|
||||
);
|
||||
$exit = $self->get_severity(label => 'operability', section => 'memoryunit', instance => $result->{dn}, value => $result->{operability});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"memory unit '%s' status is '%s'",
|
||||
$result->{dn},
|
||||
$result->{operability}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
next if (!defined($result_stats->{temperature}));
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'memoryunit.temperature', instance => $result->{dn}, value => $result_stats->{temperature});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"memory unit '%s' temperature is %s C",
|
||||
$result->{dn},
|
||||
$result_stats->{temperature}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.memoryunit.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $result->{dn},
|
||||
value => $result_stats->{temperature},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,109 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use network::cisco::firepower::fxos::snmp::mode::components::resources qw($map_operability);
|
||||
|
||||
my $mapping = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.109.1.2' }, # cfprEquipmentPsuDn
|
||||
operability => { oid => '.1.3.6.1.4.1.9.9.826.1.20.109.1.10', map => $map_operability } # cfprEquipmentPsuOperability
|
||||
};
|
||||
my $mapping_stats = {
|
||||
dn => { oid => '.1.3.6.1.4.1.9.9.826.1.20.116.1.2' }, # cfprEquipmentPsuStatsDn
|
||||
temperature => { oid => '.1.3.6.1.4.1.9.9.826.1.20.116.1.5' } # cfprEquipmentPsuStatsAmbientTempAvg
|
||||
};
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, map({ oid => $_->{oid} }, values(%$mapping), values(%$mapping_stats));
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => 'checking power supplies');
|
||||
$self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
my $results = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping)) };
|
||||
my $results_stats = { map(%{$self->{results}->{ $_->{oid} }}, values(%$mapping_stats)) };
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{operability}->{oid}\.(.*)$/);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
|
||||
|
||||
next if ($self->check_filter(section => 'psu', instance => $result->{dn}));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
my $result_stats = $self->compare_dn(
|
||||
regexp => "^$result->{dn}/",
|
||||
lookup => 'dn',
|
||||
results => $results_stats,
|
||||
mapping => $mapping_stats
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"power supply '%s' status is '%s' [temperature: %s C].",
|
||||
$result->{dn},
|
||||
$result->{operability},
|
||||
$result_stats->{temperature}
|
||||
)
|
||||
);
|
||||
$exit = $self->get_severity(label => 'operability', section => 'psu', instance => $result->{dn}, value => $result->{operability});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"power supply '%s' status is '%s'",
|
||||
$result->{dn},
|
||||
$result->{operability}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu.temperature', instance => $result->{dn}, value => $result_stats->{temperature});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"power supply '%s' temperature is %s C",
|
||||
$result->{dn},
|
||||
$result_stats->{temperature}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.powersupply.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $result->{dn},
|
||||
value => $result_stats->{temperature},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::components::resources;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Exporter;
|
||||
|
||||
our $map_operability;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw($map_operability);
|
||||
|
||||
$map_operability = {
|
||||
0 => 'unknown', 1 => 'operable',
|
||||
2 => 'inoperable', 3 => 'degraded',
|
||||
4 => 'poweredOff', 5 => 'powerProblem',
|
||||
6 => 'removed', 7 => 'voltageProblem',
|
||||
8 => 'thermalProblem', 9 => 'performanceProblem',
|
||||
10 => 'accessibilityProblem', 11 => 'identityUnestablishable',
|
||||
12 => 'biosPostTimeout', 13 => 'disabled',
|
||||
14 => 'malformedFru', 51 => 'fabricConnProblem',
|
||||
52 => 'fabricUnsupportedConn', 81 => 'config',
|
||||
82 => 'equipmentProblem', 83 => 'decomissioning',
|
||||
84 => 'chassisLimitExceeded', 100 => 'notSupported',
|
||||
101 => 'discovery', 102 => 'discoveryFailed',
|
||||
103 => 'identify', 104 => 'postFailure',
|
||||
105 => 'upgradeProblem', 106 => 'peerCommProblem',
|
||||
107 => 'autoUpgrade', 108 => 'linkActivateBlocked'
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,140 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::cpu;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{cpu} = [
|
||||
{ label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => {
|
||||
key_values => [ { name => 'average_1m' } ],
|
||||
output_template => '%.2f %% (1m)',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => {
|
||||
key_values => [ { name => 'average_5m' } ],
|
||||
output_template => '%.2f %% (5m)',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'average-15m', nlabel => 'cpu.utilization.15m.percentage', set => {
|
||||
key_values => [ { name => 'average_15m' } ],
|
||||
output_template => '%.2f %% (15m)',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_message_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Security module '" . $options{instance_value}->{display} . "' CPU average usage: ";
|
||||
}
|
||||
|
||||
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 => {
|
||||
'filter-security-module:s' => { name => 'filter_security_module' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
display => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.2' }, # cfprSmMonitorDn
|
||||
average_15m => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.5' }, # cfprSmMonitorCpuTotalLoadAvg15min
|
||||
average_1m => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.6' }, # cfprSmMonitorCpuTotalLoadAvg1min
|
||||
average_5m => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.7' } # cfprSmMonitorCpuTotalLoadAvg5min
|
||||
};
|
||||
my $oid_cfprSmMonitorEntry = '.1.3.6.1.4.1.9.9.826.1.71.20.1';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $mapping->{display}->{oid} },
|
||||
{ oid => $oid_cfprSmMonitorEntry, start => $mapping->{average_15m}->{oid}, end => $mapping->{average_5m}->{oid} }
|
||||
],
|
||||
return_type => 1,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{cpu} = {};
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping->{display}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
# remove 'monitor': sec-svc/slot-1/monitor
|
||||
$result->{display} =~ s/\/([^\/]*?)$//;
|
||||
if (defined($self->{option_results}->{filter_security_module}) && $self->{option_results}->{filter_security_module} ne '' &&
|
||||
$result->{display} !~ /$self->{option_results}->{filter_security_module}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{display} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{cpu}->{ $result->{display} } = $result;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check CPU usage.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-security-module>
|
||||
|
||||
Filter security module name.
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'average-1m' (%), 'average-5m' (%), 'average-15m' (%).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,250 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::faults;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"fault '%s' [severity: %s] [type: %s] [ack: %s] [description: %s] %s",
|
||||
$self->{result_values}->{object},
|
||||
$self->{result_values}->{severity},
|
||||
$self->{result_values}->{type},
|
||||
$self->{result_values}->{acknowledged},
|
||||
$self->{result_values}->{description},
|
||||
$self->{result_values}->{generation_time}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
sub prefix_global_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Faults ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||
{ name => 'faults', type => 2, message_multiple => '0 fault(s) detected', display_counter_problem => { nlabel => 'faults.problems.current.count', min => 0 },
|
||||
group => [ { name => 'fault', skipped_code => { -11 => 1 } } ]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'faults-total', nlabel => 'faults.total.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'total' } ],
|
||||
output_template => 'total: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
foreach (('critical', 'major', 'warning', 'minor', 'info')) {
|
||||
push @{$self->{maps_counters}->{global}},
|
||||
{ label => 'faults-' . $_, nlabel => 'faults.' . $_ . '.count', display_ok => 0, set => {
|
||||
key_values => [ { name => $_ }, { name => 'total' } ],
|
||||
output_template => $_ . ': %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, max => 'total' }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
$self->{maps_counters}->{fault} = [
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
warning_default => '%{severity} =~ /minor|warning/',
|
||||
critical_default => '%{severity} =~ /major|critical/',
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'severity' }, { name => 'type' },
|
||||
{ name => 'acknowledged'}, { name => 'since' },
|
||||
{ name => 'object' }, { name => 'description' },
|
||||
{ name => 'generation_time' }
|
||||
],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 => {
|
||||
'memory' => { name => 'memory' },
|
||||
'timezone:s' => { name => 'timezone' }
|
||||
});
|
||||
|
||||
centreon::plugins::misc::mymodule_load(
|
||||
output => $self->{output},
|
||||
module => 'DateTime',
|
||||
error_msg => "Cannot load module 'DateTime'."
|
||||
);
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
|
||||
$self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq '');
|
||||
}
|
||||
|
||||
my $map_ack = { 1 => 'yes', 2 => 'no' };
|
||||
my $map_severity = {
|
||||
0 => 'cleared', 1 => 'info', 2 => 'condition',
|
||||
3 => 'warning', 4 => 'minor',
|
||||
5 => 'major', 6 => 'critical'
|
||||
};
|
||||
my $map_type = {
|
||||
0 => 'generic', 1 => 'configuration', 2 => 'fsm',
|
||||
3 => 'network', 4 => 'server', 5 => 'management',
|
||||
6 => 'equipment', 7 => 'environmental', 8 => 'operational',
|
||||
9 => 'connectivity', 10 => 'security',
|
||||
11 => 'sysdebug', 65536 => 'any'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
object => { oid => '.1.3.6.1.4.1.9.9.826.1.1.1.1.2' }, # cfprFaultInstDn
|
||||
acknowledged => { oid => '.1.3.6.1.4.1.9.9.826.1.1.1.1.6', map => $map_ack }, # cfprFaultInstAck
|
||||
created => { oid => '.1.3.6.1.4.1.9.9.826.1.1.1.1.10' }, # cfprFaultInstCreated
|
||||
description => { oid => '.1.3.6.1.4.1.9.9.826.1.1.1.1.11' }, # cfprFaultInstDescr
|
||||
severity => { oid => '.1.3.6.1.4.1.9.9.826.1.1.1.1.20', map => $map_severity }, # cfprFaultInstSeverity
|
||||
type => { oid => '.1.3.6.1.4.1.9.9.826.1.1.1.1.22', map => $map_type } # cfprFaultInstType
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||
oids => [ map({ oid => $_->{oid} }, values(%$mapping)) ],
|
||||
return_type => 1
|
||||
);
|
||||
|
||||
my $last_time;
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->read(statefile => 'cisco_firepower_fxos_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port(). '_' . $self->{mode});
|
||||
$last_time = $self->{statefile_cache}->get(name => 'last_time');
|
||||
}
|
||||
|
||||
$self->{global} = { total => 0, critical => 0, major => 0, warning => 0, minor => 0, info => 0 };
|
||||
$self->{faults}->{global} = { fault => {} };
|
||||
|
||||
my $current_time = time();
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping->{severity}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
my @date = unpack 'n C6 a C2', $result->{created};
|
||||
my $timezone = $self->{option_results}->{timezone};
|
||||
if (defined($date[8])) {
|
||||
$timezone = sprintf("%s%02d%02d", $date[7], $date[8], $date[9]);
|
||||
}
|
||||
|
||||
my $tz = centreon::plugins::misc::set_timezone(name => $timezone);
|
||||
my $dt = DateTime->new(
|
||||
year => $date[0], month => $date[1], day => $date[2], hour => $date[3], minute => $date[4], second => $date[5],
|
||||
%$tz
|
||||
);
|
||||
|
||||
next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $dt->epoch);
|
||||
|
||||
my $diff_time = $current_time - $dt->epoch();
|
||||
|
||||
$self->{faults}->{global}->{fault}->{ $result->{object} } = {
|
||||
since => $diff_time,
|
||||
generation_time => centreon::plugins::misc::change_seconds(value => $diff_time),
|
||||
%$result
|
||||
};
|
||||
|
||||
$self->{global}->{total}++;
|
||||
$self->{global}->{ $result->{severity} }++
|
||||
if (defined($self->{global}->{ $result->{severity} }));
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->write(data => { last_time => $current_time });
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check faults.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{severity} =~ /minor|warning/).
|
||||
Can used special variables like: %{description}, %{object}, %{severity}, %{type}, %{acknowledged}, %{since}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{severity} =~ /major|critical/').
|
||||
Can used special variables like: %{description}, %{object}, %{severity}, %{type}, %{since}
|
||||
|
||||
=item B<--timezone>
|
||||
|
||||
Timezone options (the date from the equipment overload that option). Default is 'GMT'.
|
||||
|
||||
=item B<--memory>
|
||||
|
||||
Only check new alarms.
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'faults-total', 'faults-critical', 'faults-major', 'faults-warning', 'faults-minor', 'faults-info'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,151 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} =
|
||||
'^(?:(?:fanmodule|memoryunit|cpuunit|psu)\.temperature|fan\.speed|chassis\.(?:input|output)power)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
operability => [
|
||||
['operable', 'OK'],
|
||||
['unknown', 'OK'],
|
||||
['inoperable', 'CRITICAL'],
|
||||
['degraded', 'WARNING'],
|
||||
['poweredOff', 'OK'],
|
||||
['powerProblem', 'CRITICAL'],
|
||||
['removed', 'OK'],
|
||||
['voltageProblem', 'CRITICAL'],
|
||||
['thermalProblem', 'CRITICAL'],
|
||||
['performanceProblem', 'CRITICAL'],
|
||||
['accessibilityProblem', 'WARNING'],
|
||||
['identityUnestablishable', 'CRITICAL'],
|
||||
['biosPostTimeout', 'CRITICAL'],
|
||||
['disabled', 'OK'],
|
||||
['malformedFru', 'CRITICAL'],
|
||||
['fabricConnProblem', 'WARNING'],
|
||||
['fabricUnsupportedConn', 'CRITICAL'],
|
||||
['config', 'OK'],
|
||||
['equipmentProblem', 'CRITICAL'],
|
||||
['decomissioning', 'OK'],
|
||||
['chassisLimitExceeded', 'WARNING'],
|
||||
['notSupported', 'WARNING'],
|
||||
['discovery', 'OK'],
|
||||
['discoveryFailed', 'WARNING'],
|
||||
['identify', 'OK'],
|
||||
['postFailure', 'WARNING'],
|
||||
['upgradeProblem', 'CRITICAL'],
|
||||
['peerCommProblem', 'CRITICAL'],
|
||||
['autoUpgrade', 'WARNING'],
|
||||
['linkActivateBlocked', 'WARNING']
|
||||
]
|
||||
};
|
||||
|
||||
$self->{components_path} = 'network::cisco::firepower::fxos::snmp::mode::components';
|
||||
$self->{components_module} = ['chassis', 'fan', 'fanmodule', 'psu', 'cpuunit', 'memoryunit'];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub compare_dn {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result_stats;
|
||||
foreach (%{$options{results}}) {
|
||||
next if (! /^$options{mapping}->{ $options{lookup} }->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
if ($options{results}->{$_} =~ /$options{regexp}/) {
|
||||
$result_stats = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $options{results}, instance => $instance);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return $result_stats;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check hardware.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'chassis', 'fan', 'fanmodule', 'psu', 'cpuunit', 'memoryunit'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan)
|
||||
Can also exclude specific instance: --filter=fan,chassis-1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='fan,WARNING,removed'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold (syntax: type,regexp,threshold)
|
||||
Example: --warning='temperature,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold (syntax: type,regexp,threshold)
|
||||
Example: --critical='temperature,.*,40'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,163 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::mode::memory;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)',
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{total}),
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{used}),
|
||||
$self->{result_values}->{prct_used},
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{free}),
|
||||
$self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'memory', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All memory usages are ok' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{memory} = [
|
||||
{ label => 'usage', nlabel => 'memory.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ value => 'used', template => '%d', min => 0, max => 'total',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ value => 'free', template => '%d', min => 0, max => 'total',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'display' } ],
|
||||
output_template => 'Ram Used : %.2f %%',
|
||||
perfdatas => [
|
||||
{ value => 'prct_used', template => '%.2f', min => 0, max => 100,
|
||||
unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_message_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Security module '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
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 => {
|
||||
'filter-security-module:s' => { name => 'filter_security_module' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
display => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.2' }, # cfprSmMonitorDn
|
||||
free => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.9' }, # cfprSmMonitorMemFreeKb
|
||||
total => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.10' } # cfprSmMonitorMemTotalKb
|
||||
};
|
||||
my $oid_cfprSmMonitorEntry = '.1.3.6.1.4.1.9.9.826.1.71.20.1';
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $mapping->{display}->{oid} },
|
||||
{ oid => $oid_cfprSmMonitorEntry, start => $mapping->{free}->{oid}, end => $mapping->{total}->{oid} }
|
||||
],
|
||||
return_type => 1,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{memory} = {};
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping->{display}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
# remove 'monitor': sec-svc/slot-1/monitor
|
||||
$result->{display} =~ s/\/([^\/]*?)$//;
|
||||
if (defined($self->{option_results}->{filter_security_module}) && $self->{option_results}->{filter_security_module} ne '' &&
|
||||
$result->{display} !~ /$self->{option_results}->{filter_security_module}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $result->{display} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$result->{total} *= 1024;
|
||||
$result->{free} *= 1024;
|
||||
my $prct_used = ($result->{total} - $result->{free}) * 100 / $result->{total};
|
||||
$self->{memory}->{ $result->{display} } = {
|
||||
prct_used => $prct_used,
|
||||
prct_free => 100 - $prct_used,
|
||||
used => $result->{total} - $result->{free},
|
||||
%$result
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check memory usage.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-switch-num>
|
||||
|
||||
Filter switch number.
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,53 @@
|
|||
#
|
||||
# Copyright 2020 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 network::cisco::firepower::fxos::snmp::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_snmp);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$self->{modes} = {
|
||||
'cpu' => 'network::cisco::firepower::fxos::snmp::mode::cpu',
|
||||
'faults' => 'network::cisco::firepower::fxos::snmp::mode::faults',
|
||||
'hardware' => 'network::cisco::firepower::fxos::snmp::mode::hardware',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::cisco::firepower::fxos::snmp::mode::memory'
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Cisco Firepower FXOS in SNMP.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue