From 9d5eef78f3262fd4a98b226c84e2411016018119 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 25 Feb 2020 11:45:10 +0100 Subject: [PATCH] add filter core cpu fortigate --- .../common/fortinet/fortigate/snmp/mode/cpu.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm b/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm index 605d163c5..6bb459f89 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm @@ -89,7 +89,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'cluster' => { name => 'cluster' } + 'cluster' => { name => 'cluster' }, + 'filter-core' => { name => 'filter_core' }, }); return $self; @@ -132,12 +133,18 @@ sub manage_selection { nothing_quit => 1 ); - my ($cpu, $i) = (0, 0); + my ($cpu, $i) = (0, -1); $self->{cpu_core} = {}; foreach ($options{snmp}->oid_lex_sort(keys %{$snmp_result->{$oid_fgProcessorUsage}})) { + $i++; + if (defined($self->{option_results}->{filter_core}) && $self->{option_results}->{filter_core} ne '' && + $i !~ /$self->{option_results}->{filter_core}/) { + $self->{output}->output_add(long_msg => "skipping core cpu '" . $i . "': no matching filter.", debug => 1); + next; + } + $self->{cpu_core}->{$i} = { display => $i, cpu => $snmp_result->{$oid_fgProcessorUsage}->{$_} }; $cpu += $snmp_result->{$oid_fgProcessorUsage}->{$_}; - $i++; } $self->{cpu_avg} = { @@ -173,6 +180,10 @@ Can be: 'core', 'average', 'cluster-average'. Add cluster cpu informations. +=item B<--filter-core> + +Core cpu to monitor (can be a regexp). + =back =cut