Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4909454
fix(ci): add missing image + fix path for tests on noble
omercier Mar 20, 2025
9274e64
fix(ci): add missing image + fix path for tests on noble (#5516)
omercier Mar 21, 2025
e74825a
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 9, 2025
75a686f
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 23, 2025
06d9cca
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 29, 2025
a655ae5
Merge branch 'centreon:develop' into develop
garnier-quentin May 13, 2025
0e2a2c2
Merge branch 'centreon:develop' into develop
garnier-quentin May 14, 2025
868a37b
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 4, 2025
6fd626e
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 12, 2025
cf2d401
Merge branch 'centreon:develop' into develop
garnier-quentin Jul 17, 2025
7930cbe
Merge branch 'centreon:develop' into develop
garnier-quentin Sep 16, 2025
7ef7c1c
Merge branch 'centreon:develop' into develop
garnier-quentin Sep 25, 2025
adbb960
Merge branch 'centreon:develop' into develop
garnier-quentin Dec 11, 2025
4b45367
Merge branch 'centreon:develop' into develop
garnier-quentin Dec 22, 2025
dc85ae4
Merge branch 'centreon:develop' into develop
garnier-quentin Jan 7, 2026
4243e13
Merge branch 'centreon:develop' into develop
garnier-quentin Feb 10, 2026
b6020da
Merge branch 'centreon:develop' into develop
garnier-quentin Mar 16, 2026
339e322
Merge branch 'centreon:develop' into develop
garnier-quentin Mar 26, 2026
15da907
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 8, 2026
ffa1515
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 8, 2026
b1f102a
wip
garnier-quentin Jun 8, 2026
84033c9
wip
garnier-quentin Jun 8, 2026
d10a1f1
Merge branch 'centreon:develop' into CTOR-2380-paloalto-new-modes
garnier-quentin Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 204 additions & 0 deletions src/network/paloalto/api/mode/cpu.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
#
# Copyright 2026-Present 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::paloalto::api::mode::cpu;

use base qw(centreon::plugins::templates::counter);

use strict;
use warnings;
use centreon::plugins::constants qw(:counters);
use centreon::plugins::misc qw(is_excluded);

sub custom_perfdata {
my ($self, %options) = @_;

$self->{output}->perfdata_add(
nlabel => $self->{nlabel},
instances => ['dp' . $self->{result_values}->{dpNum}, 'cpu' . $self->{result_values}->{cpuNum}],
value => sprintf('%.2f', $self->{result_values}->{ $self->{key_values}->[0]->{name} }),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0,
max => 100,
unit => '%'
);
}

sub prefix_cpu_core_output {
my ($self, %options) = @_;

return "CPU '" . $options{instance_value}->{cpuNum} . "' ";
}

sub long_dp_output {
my ($self, %options) = @_;

return sprintf(
"checking data processor '%s'",
$options{instance_value}->{dpNum}
);
}

sub prefix_dp_output {
my ($self, %options) = @_;

return sprintf(
"data processor '%s' ",
$options{instance_value}->{dpNum}
);
}

sub set_counters {
my ($self, %options) = @_;

$self->{maps_counters_type} = [
{ name => 'dp', type => COUNTER_TYPE_MULTIPLE, cb_prefix_output => 'prefix_dp_output', cb_long_output => 'long_dp_output',
message_multiple => 'All data processors are ok', indent_long_output => ' ',
group => [
{ name => 'cpu_cores', display_long => 1, cb_prefix_output => 'prefix_cpu_core_output', message_multiple => 'All CPU cores are ok', type => COUNTER_MULTIPLE_SUBINSTANCE, sort_method => 'num' }
]
}
];

$self->{maps_counters}->{cpu_cores} = [
{ label => 'average-1m', nlabel => 'core.cpu.utilization.1m.percentage', set => {
key_values => [ { name => 'average_1m' }, { name => 'dpNum' }, { name => 'cpuNum' } ],
output_template => '%.2f %% (1m)',
closure_custom_perfdata => $self->can('custom_perfdata')
}
},
{ label => 'average-5m', nlabel => 'core.cpu.utilization.5m.percentage', set => {
key_values => [ { name => 'average_5m' }, { name => 'dpNum' }, { name => 'cpuNum' } ],
output_template => '%.2f %% (5m)',
closure_custom_perfdata => $self->can('custom_perfdata'),
}
},
{ label => 'average-15m', nlabel => 'core.cpu.utilization.15m.percentage', set => {
key_values => [ { name => 'average_15m' }, { name => 'dpNum' }, { name => 'cpuNum' } ],
output_template => '%.2f %% (15m)',
closure_custom_perfdata => $self->can('custom_perfdata')
}
}
];
}

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 => {
'include-dp-name:s' => { name => 'include_dp_name', default => '' },
'exclude-dp-name:s' => { name => 'exclude_dp_name', default => '' }
});

return $self;
}

sub compute_cpu_average {
my ($self, %options) = @_;

my $value = 0;
for (my $i = 0; $i < $options{sampling}; $i++) {
$value += $options{dataset}->[$i];
}

$value /= $options{sampling};

return $value;
}

sub manage_selection {
my ($self, %options) = @_;

my $result = $options{custom}->request_api(
type => 'op',
cmd => '<show><running><resource-monitor></resource-monitor></running></show>',
ForceArray => ['entry']
);

$self->{dp} = {};
foreach my $dp (keys %{$result->{'resource-monitor'}->{'data-processors'}}) {
next if ($dp !~ /dp(\d+)/);
my $dp_num = $1;

next if is_excluded($dp_num, $self->{option_results}->{include_dp_name}, $self->{option_results}->{exclude_dp_name});

$self->{dp}->{$dp_num} = { dpNum => $dp_num, cpu_cores => {} };

foreach my $core (@{$result->{'resource-monitor'}->{'data-processors'}->{$dp}->{minute}->{'cpu-load-average'}->{entry}}) {
my @datas = split(/,/, $core->{value});
$self->{dp}->{$dp_num}->{cpu_cores}->{ $core->{coreid} } = {
dpNum => $dp_num,
cpuNum => $core->{coreid},
average_1m => $self->compute_cpu_average(dataset => \@datas, sampling => 1),
average_5m => $self->compute_cpu_average(dataset => \@datas, sampling => 5),
average_15m => $self->compute_cpu_average(dataset => \@datas, sampling => 15)
};
}
}
}

1;

__END__

=head1 MODE

Check data processors.

=over 8

=item B<--include-dp-name>

Include data processor names (regexp).

=item B<--exclude-dp-name>

Exclude data processor names (regexp).

=item B<--warning-average-1m>

Warning threshold for data processor 1 minute average usage in percent.

=item B<--critical-average-1m>

Critical threshold for data processor 1 minute average usage in percent.

=item B<--warning-average-5m>

Warning threshold for data processor 5 minutes average usage in percent.

=item B<--critical-average-5m>

Critical threshold for data processor 5 minutes average usage in percent.

=item B<--warning-average-15m>

Warning threshold for data processor 15 minutes average usage in percent.

=item B<--critical-average-15m>

Critical threshold for data processor 15 minutes average usage in percent.

=back

=cut
Loading