From a8378aa1cb0e5043841d239f61a2f6c1523e5434 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 23 Apr 2021 09:37:07 +0200 Subject: [PATCH] fix(aws/health): events mode - limit issue with paws (#2732) --- centreon-plugins/cloud/aws/custom/paws.pm | 33 +++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/centreon-plugins/cloud/aws/custom/paws.pm b/centreon-plugins/cloud/aws/custom/paws.pm index 59513974d..a796337fb 100644 --- a/centreon-plugins/cloud/aws/custom/paws.pm +++ b/centreon-plugins/cloud/aws/custom/paws.pm @@ -619,25 +619,24 @@ sub health_describe_affected_entities { eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $health = Paws->service('Health', caller => $lwp_caller, region => $self->{option_results}->{region}); - my $health_options = { Filter => {} }; - if (defined($options{filter_event_arns})) { - $health_options->{Filter}->{EventArns} = $options{filter_event_arns}; - } - while ((my $entities = $health->DescribeAffectedEntities(%$health_options))) { - foreach (@{$entities->{Entities}}) { - push @$entities_results, { - entityArn => $_->{EntityArn}, - eventArn => $_->{EventArn}, - entityValue => $_->{EntityValue}, - awsAccountId => $_->{AwsAccountId}, - lastUpdatedTime => $_->{LastUpdatedTime}, - statusCode => $_->{StatusCode} - }; + while (my @events = splice(@{$options{filter_event_arns}}, 0, 10)) { + my $health_options = { Filter => { EventArns => \@events } }; + while ((my $entities = $health->DescribeAffectedEntities(%$health_options))) { + foreach (@{$entities->{Entities}}) { + push @$entities_results, { + entityArn => $_->{EntityArn}, + eventArn => $_->{EventArn}, + entityValue => $_->{EntityValue}, + awsAccountId => $_->{AwsAccountId}, + lastUpdatedTime => $_->{LastUpdatedTime}, + statusCode => $_->{StatusCode} + }; + } + + last if (!defined($entities->{NextToken})); + $health_options->{NextToken} = $entities->{NextToken}; } - - last if (!defined($entities->{NextToken})); - $health_options->{NextToken} = $entities->{NextToken}; } }; if ($@) {