centreon-plugins/network/radware/alteon/snmp/mode/cpu.pm

243 lines
8.4 KiB
Perl
Raw Normal View History

2013-12-13 16:14:12 +01:00
#
2021-02-08 09:55:50 +01:00
# Copyright 2021 Centreon (http://www.centreon.com/)
2015-07-21 11:51:02 +02:00
#
# 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.
#
2013-12-13 16:14:12 +01:00
2017-03-28 14:35:52 +02:00
package network::radware::alteon::snmp::mode::cpu;
2013-12-13 16:14:12 +01:00
2017-03-29 17:01:02 +02:00
use base qw(centreon::plugins::templates::counter);
2013-12-13 16:14:12 +01:00
use strict;
use warnings;
2017-03-29 17:01:02 +02:00
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
2017-11-29 15:29:15 +01:00
{ name => 'mp_cpu', type => 0, cb_prefix_output => 'prefix_mp_cpu_output', skipped_code => { -10 => 1 } },
{ name => 'sp_ga_avg', type => 0, skipped_code => { -10 => 1 } },
{ name => 'sp_ga', type => 1, cb_init => 'skip_sp_ga', cb_prefix_output => 'prefix_sp_ga_output', message_multiple => 'All SP GA CPU are ok' },
2017-03-29 17:01:02 +02:00
];
2017-11-29 15:29:15 +01:00
$self->{maps_counters}->{mp_cpu} = [
{ label => 'mp-1s', set => {
key_values => [ { name => 'mp_1s' } ],
2017-03-29 17:01:02 +02:00
output_template => '%.2f%% (1sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'mp_cpu_1s', value => 'mp_1s', template => '%.2f',
2017-03-29 17:01:02 +02:00
min => 0, max => 100, unit => '%' },
],
}
},
2017-11-29 15:29:15 +01:00
{ label => 'mp-4s', set => {
key_values => [ { name => 'mp_4s' } ],
2017-03-29 17:01:02 +02:00
output_template => '%.2f%% (4sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'mp_cpu_4s', value => 'mp_4s', template => '%.2f',
2017-03-29 17:01:02 +02:00
min => 0, max => 100, unit => '%' },
],
}
},
2017-11-29 15:29:15 +01:00
{ label => 'mp-64s', set => {
key_values => [ { name => 'mp_64s' } ],
2017-03-29 17:01:02 +02:00
output_template => '%.2f%% (64sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'mp_cpu_64s', value => 'mp_64s', template => '%.2f',
2017-03-29 17:01:02 +02:00
min => 0, max => 100, unit => '%' },
],
}
},
];
2017-11-29 15:29:15 +01:00
$self->{maps_counters}->{sp_ga_avg} = [
{ label => 'sp-ga-avg-1s', set => {
key_values => [ { name => 'sp_1s' } ],
output_template => 'SP GA Average CPU Usage: %.2f%% (1sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'avg_spga_cpu_1s', value => 'sp_1s', template => '%.2f',
2017-11-29 15:29:15 +01:00
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'sp-ga-avg-4s', set => {
key_values => [ { name => 'sp_4s' } ],
output_template => '%.2f%% (4sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'avg_spga_cpu_4s', value => 'sp_4s', template => '%.2f',
2017-11-29 15:29:15 +01:00
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'sp-ga-avg-64s', set => {
key_values => [ { name => 'sp_64s' } ],
output_template => '%.2f%% (64sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'avg_spga_cpu_64s', value => 'sp_64s', template => '%.2f',
2017-11-29 15:29:15 +01:00
min => 0, max => 100, unit => '%' },
],
}
},
];
$self->{maps_counters}->{sp_ga} = [
{ label => 'sp-ga-1s', set => {
key_values => [ { name => 'sp_1s' }, { name => 'display' } ],
output_template => '%.2f%% (1sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'spga_cpu_1s', value => 'sp_1s', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' },
2017-11-29 15:29:15 +01:00
],
}
},
{ label => 'sp-ga-4s', set => {
key_values => [ { name => 'sp_4s' }, { name => 'display' } ],
output_template => '%.2f%% (4sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'spga_cpu_4s', value => 'sp_4s', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' },
2017-11-29 15:29:15 +01:00
],
}
},
{ label => 'sp-ga-64s', set => {
key_values => [ { name => 'sp_64s' }, { name => 'display' } ],
output_template => '%.2f%% (64sec)',
perfdatas => [
2020-05-13 14:18:28 +02:00
{ label => 'spga_cpu_64s', value => 'sp_64s', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' },
2017-11-29 15:29:15 +01:00
],
}
},
];
2017-03-29 17:01:02 +02:00
}
2017-11-29 15:29:15 +01:00
sub prefix_mp_cpu_output {
2017-03-29 17:01:02 +02:00
my ($self, %options) = @_;
return "MP CPU Usage: ";
}
2017-11-29 15:29:15 +01:00
sub prefix_sp_ga_output {
my ($self, %options) = @_;
return "SP GA CPU '" . $options{instance_value}->{display} . "' Usage: ";
}
sub skip_sp_ga {
my ($self, %options) = @_;
scalar(keys %{$self->{sp_ga}}) <= 0 ? return(1) : return(0);
}
2013-12-13 16:14:12 +01:00
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
return $self;
}
2017-11-29 15:29:15 +01:00
my $mapping = {
mpCpuStatsUtil1Second => { oid => '.1.3.6.1.4.1.1872.2.5.1.2.2.1' },
mpCpuStatsUtil4Seconds => { oid => '.1.3.6.1.4.1.1872.2.5.1.2.2.2' },
mpCpuStatsUtil64Seconds => { oid => '.1.3.6.1.4.1.1872.2.5.1.2.2.3' },
};
my $mapping2 = {
spGAStatsCpuUtil1Second => { oid => '.1.3.6.1.4.1.1872.2.5.1.2.13.1.1.3' },
spGAStatsCpuUtil4Seconds => { oid => '.1.3.6.1.4.1.1872.2.5.1.2.13.1.1.4' },
spGAStatsCpuUtil64Seconds => { oid => '.1.3.6.1.4.1.1872.2.5.1.2.13.1.1.5' },
};
my $oid_mpCpuStats = '.1.3.6.1.4.1.1872.2.5.1.2.2';
my $oid_spGAStatsCpuUtilTableEntry = '.1.3.6.1.4.1.1872.2.5.1.2.13.1.1';
2017-03-29 17:01:02 +02:00
sub manage_selection {
2013-12-13 16:14:12 +01:00
my ($self, %options) = @_;
2017-11-29 15:29:15 +01:00
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_mpCpuStats }, { oid => $oid_spGAStatsCpuUtilTableEntry } ],
return_type => 1, nothing_quit => 1);
$self->{sp_ga} = {};
my ($avg_sp_1s, $avg_sp_4s, $avg_sp_64s) = (0, 0, 0);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping2->{spGAStatsCpuUtil64Seconds}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $instance);
$self->{sp_ga}->{$instance} = {
display => $instance,
sp_1s => $result->{spGAStatsCpuUtil1Second},
sp_4s => $result->{spGAStatsCpuUtil4Seconds},
sp_64s => $result->{spGAStatsCpuUtil64Seconds},
};
$avg_sp_1s += $result->{spGAStatsCpuUtil1Second};
$avg_sp_4s += $result->{spGAStatsCpuUtil4Seconds};
$avg_sp_64s += $result->{spGAStatsCpuUtil64Seconds};
}
$self->{sp_ga_avg} = {};
if (scalar(keys %{$self->{sp_ga}}) > 1) {
$self->{sp_ga_avg} = {
sp_1s => $avg_sp_1s / scalar(keys %{$self->{sp_ga}}),
sp_4s => $avg_sp_4s / scalar(keys %{$self->{sp_ga}}),
sp_64s => $avg_sp_64s / scalar(keys %{$self->{sp_ga}}),
};
}
$self->{mp_cpu} = {
mp_1s => $snmp_result->{$mapping->{mpCpuStatsUtil1Second}->{oid} . '.0'},
mp_4s => $snmp_result->{$mapping->{mpCpuStatsUtil4Seconds}->{oid} . '.0'},
mp_64s => $snmp_result->{$mapping->{mpCpuStatsUtil64Seconds}->{oid} . '.0'},
};
2013-12-13 16:14:12 +01:00
}
1;
__END__
=head1 MODE
Check MP cpu usage (ALTEON-CHEETAH-SWITCH-MIB).
=over 8
2017-03-29 17:01:02 +02:00
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^(64s)$'
=item B<--warning-*>
2013-12-13 16:14:12 +01:00
2017-03-29 17:01:02 +02:00
Threshold warning.
2017-11-29 15:29:15 +01:00
Can be: 'mp-1s', 'mp-4s', 'mp-64s',
'sp-ga-1s', 'sp-ga-4s', 'sp-ga-64s',
'sp-ga-avg-1s', 'sp-ga-avg-4s', 'sp-ga-avg-64s'.
2013-12-13 16:14:12 +01:00
2017-03-29 17:01:02 +02:00
=item B<--critical-*>
2013-12-13 16:14:12 +01:00
2017-03-29 17:01:02 +02:00
Threshold critical.
2017-11-29 15:29:15 +01:00
Can be: 'mp-1s', 'mp-4s', 'mp-64s',
'sp-ga-1s', 'sp-ga-4s', 'sp-ga-64s',
'sp-ga-avg-1s', 'sp-ga-avg-4s', 'sp-ga-avg-64s'.
2013-12-13 16:14:12 +01:00
=back
=cut
2017-11-29 15:29:15 +01:00