| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::cisco::firepower::fxos::snmp::mode::cpu; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub set_counters { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{maps_counters_type} = [ |
| 32 |
{ name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' } |
| 33 |
]; |
| 34 |
|
| 35 |
$self->{maps_counters}->{cpu} = [ |
| 36 |
{ label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { |
| 37 |
key_values => [ { name => 'average_1m' } ], |
| 38 |
output_template => '%.2f %% (1m)', |
| 39 |
perfdatas => [ |
| 40 |
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } |
| 41 |
] |
| 42 |
} |
| 43 |
}, |
| 44 |
{ label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => { |
| 45 |
key_values => [ { name => 'average_5m' } ], |
| 46 |
output_template => '%.2f %% (5m)', |
| 47 |
perfdatas => [ |
| 48 |
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } |
| 49 |
] |
| 50 |
} |
| 51 |
}, |
| 52 |
{ label => 'average-15m', nlabel => 'cpu.utilization.15m.percentage', set => { |
| 53 |
key_values => [ { name => 'average_15m' } ], |
| 54 |
output_template => '%.2f %% (15m)', |
| 55 |
perfdatas => [ |
| 56 |
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } |
| 57 |
] |
| 58 |
} |
| 59 |
} |
| 60 |
]; |
| 61 |
} |
| 62 |
|
| 63 |
sub prefix_message_output { |
| 64 |
my ($self, %options) = @_; |
| 65 |
|
| 66 |
return "Security module '" . $options{instance_value}->{display} . "' CPU average usage: "; |
| 67 |
} |
| 68 |
|
| 69 |
sub new { |
| 70 |
my ($class, %options) = @_; |
| 71 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 72 |
bless $self, $class; |
| 73 |
|
| 74 |
$options{options}->add_options(arguments => { |
| 75 |
'filter-security-module:s' => { name => 'filter_security_module' } |
| 76 |
}); |
| 77 |
|
| 78 |
return $self; |
| 79 |
} |
| 80 |
|
| 81 |
my $mapping = { |
| 82 |
display => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.2' }, # cfprSmMonitorDn |
| 83 |
average_15m => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.5' }, # cfprSmMonitorCpuTotalLoadAvg15min |
| 84 |
average_1m => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.6' }, # cfprSmMonitorCpuTotalLoadAvg1min |
| 85 |
average_5m => { oid => '.1.3.6.1.4.1.9.9.826.1.71.20.1.7' } # cfprSmMonitorCpuTotalLoadAvg5min |
| 86 |
}; |
| 87 |
my $oid_cfprSmMonitorEntry = '.1.3.6.1.4.1.9.9.826.1.71.20.1'; |
| 88 |
|
| 89 |
sub manage_selection { |
| 90 |
my ($self, %options) = @_; |
| 91 |
|
| 92 |
my $snmp_result = $options{snmp}->get_multiple_table( |
| 93 |
oids => [ |
| 94 |
{ oid => $mapping->{display}->{oid} }, |
| 95 |
{ oid => $oid_cfprSmMonitorEntry, start => $mapping->{average_15m}->{oid}, end => $mapping->{average_5m}->{oid} } |
| 96 |
], |
| 97 |
return_type => 1, |
| 98 |
nothing_quit => 1 |
| 99 |
); |
| 100 |
|
| 101 |
$self->{cpu} = {}; |
| 102 |
foreach my $oid (keys %$snmp_result) { |
| 103 |
next if ($oid !~ /^$mapping->{display}->{oid}\.(.*)$/); |
| 104 |
my $instance = $1; |
| 105 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 106 |
|
| 107 |
# remove 'monitor': sec-svc/slot-1/monitor |
| 108 |
$result->{display} =~ s/\/([^\/]*?)$//; |
| 109 |
if (defined($self->{option_results}->{filter_security_module}) && $self->{option_results}->{filter_security_module} ne '' && |
| 110 |
$result->{display} !~ /$self->{option_results}->{filter_security_module}/) { |
| 111 |
$self->{output}->output_add(long_msg => "skipping '" . $result->{display} . "': no matching filter.", debug => 1); |
| 112 |
next; |
| 113 |
} |
| 114 |
|
| 115 |
$self->{cpu}->{ $result->{display} } = $result; |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
1; |
| 120 |
|
| 121 |
__END__ |
| 122 |
|
| 123 |
=head1 MODE |
| 124 |
|
| 125 |
Check CPU usage. |
| 126 |
|
| 127 |
=over 8 |
| 128 |
|
| 129 |
=item B<--filter-security-module> |
| 130 |
|
| 131 |
Filter security module name. |
| 132 |
|
| 133 |
=item B<--warning-*> B<--critical-*> |
| 134 |
|
| 135 |
Thresholds. |
| 136 |
Can be: 'average-1m' (%), 'average-5m' (%), 'average-15m' (%). |
| 137 |
|
| 138 |
=back |
| 139 |
|
| 140 |
=cut |