enhance aws health
This commit is contained in:
parent
c62568ff60
commit
f0f038dd79
|
@ -674,13 +674,11 @@ sub health_describe_events_set_cmd {
|
|||
my $cmd_options = "health describe-events --region $self->{option_results}->{region} --output json";
|
||||
|
||||
my ($filter, $filter_append) = ('', '');
|
||||
foreach ((['service', 'services'], ['region', 'regions'], ['entity_value', 'entityValues'], ['event_status', 'eventStatusCodes'])) {
|
||||
next if (!defined($options{ $_->[0] }));
|
||||
foreach ((['service', 'services'], ['region', 'regions'], ['entity_value', 'entityValues'], ['event_status', 'eventStatusCodes'], ['event_category', 'eventTypeCategories'])) {
|
||||
next if (!defined($options{ 'filter_' . $_->[0] }));
|
||||
|
||||
foreach my $entry (@{$options{ $_->[0] }}) {
|
||||
$filter .= $filter_append . $_->[1] . '=' . $entry;
|
||||
$filter_append = ',';
|
||||
}
|
||||
$filter .= $filter_append . $_->[1] . '=' . join(',', @{$options{ 'filter_' . $_->[0] }});
|
||||
$filter_append = ',';
|
||||
}
|
||||
|
||||
$cmd_options .= " --filter '$filter'" if ($filter ne '');
|
||||
|
@ -705,12 +703,9 @@ sub health_describe_affected_entities_set_cmd {
|
|||
|
||||
my $cmd_options = "health describe-affected-entities --region $self->{option_results}->{region} --output json";
|
||||
|
||||
my ($filter, $filter_append) = ('', '');
|
||||
my $filter = '';
|
||||
if (defined($options{filter_event_arns})) {
|
||||
foreach my $entry (@{$options{filter_event_arns}}) {
|
||||
$filter .= $filter_append . 'eventArns=' . $entry;
|
||||
$filter_append = ',';
|
||||
}
|
||||
$filter = 'eventArns=' . join(',', @{$options{filter_event_arns}});
|
||||
}
|
||||
|
||||
$cmd_options .= " --filter '$filter'" if ($filter ne '');
|
||||
|
@ -722,10 +717,14 @@ sub health_describe_affected_entities_set_cmd {
|
|||
sub health_describe_affected_entities {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->health_describe_affected_entities_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
my $all_results = [];
|
||||
while (my @elements = splice(@{$options{filter_event_arns}}, 0, 10)) {
|
||||
my $cmd_options = $self->health_describe_affected_entities_set_cmd(filter_event_arns => \@elements);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
push $all_results, @{$raw_results->{entities}};
|
||||
}
|
||||
|
||||
return $raw_results->{entities};
|
||||
return $all_results;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -579,7 +579,7 @@ sub health_describe_events {
|
|||
my $lwp_caller = new Paws::Net::LWPCaller();
|
||||
my $health = Paws->service('Health', caller => $lwp_caller, region => $self->{option_results}->{region});
|
||||
my $health_options = { Filter => {} };
|
||||
foreach ((['service', 'Services'], ['region', 'Regions'], ['entity_value', 'EntityValues'], ['event_status', 'EventStatusCodes'])) {
|
||||
foreach ((['service', 'Services'], ['region', 'Regions'], ['entity_value', 'EntityValues'], ['event_status', 'EventStatusCodes'], ['event_category', 'EventTypeCategories'])) {
|
||||
next if (!defined($options{ $_->[0] }));
|
||||
$health_options->{Filter}->{ $_->[1] } = $_->[0];
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', cb_prefix_output => 'prefix_global_output', type => 0 },
|
||||
|
||||
{ name => 'global', cb_prefix_output => 'prefix_global_output', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
|
@ -56,7 +55,7 @@ sub set_counters {
|
|||
]
|
||||
}
|
||||
},
|
||||
{ label => 'closed', nlabel => 'events.closed.count', set => {
|
||||
{ label => 'closed', nlabel => 'events.closed.count', set => {
|
||||
key_values => [ { name => 'closed' } ],
|
||||
output_template => 'closed: %s',
|
||||
perfdatas => [
|
||||
|
@ -81,10 +80,12 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-service:s@' => { name => 'filter_service' },
|
||||
'filter-region:s@' => { name => 'filter_region' },
|
||||
'filter-entity-value:s@' => { name => 'filter_entity_value' },
|
||||
'filter-event-status:s@' => { name => 'filter_event_status' }
|
||||
'filter-service:s@' => { name => 'filter_service' },
|
||||
'filter-region:s@' => { name => 'filter_region' },
|
||||
'filter-entity-value:s@' => { name => 'filter_entity_value' },
|
||||
'filter-event-status:s@' => { name => 'filter_event_status' },
|
||||
'filter-event-category:s@' => { name => 'filter_event_category' },
|
||||
'display-affected-entities' => { name => 'display_affected_entities' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -95,7 +96,7 @@ sub check_options {
|
|||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{filter_options} = {};
|
||||
foreach (('service', 'region', 'entity_value', 'event_status')) {
|
||||
foreach (('service', 'region', 'entity_value', 'event_status', 'event_category')) {
|
||||
$self->{filter_options}->{'filter_' . $_} = undef;
|
||||
if (defined($self->{option_results}->{'filter_' . $_})) {
|
||||
foreach my $option (@{$self->{option_results}->{'filter_' . $_}}) {
|
||||
|
@ -126,8 +127,8 @@ sub manage_selection {
|
|||
|
||||
my $affected_entities;
|
||||
my @event_arns = sort { $events->{$b}->{startTime} cmp $events->{$a}->{startTime} } keys %$events;
|
||||
if (scalar(@event_arns) > 0) {
|
||||
$affected_entities = $options{custom}->health_describe_affected_entities(filter_event_arns => \@event_arns);
|
||||
if (scalar(@event_arns) > 0 && defined($self->{option_results}->{display_affected_entities})) {
|
||||
$affected_entities = $options{custom}->health_describe_affected_entities(filter_event_arns => [@event_arns]);
|
||||
}
|
||||
|
||||
foreach (@event_arns) {
|
||||
|
@ -186,6 +187,15 @@ Example: --filter-entity-value=i-34ab692e --filter-entity-value=vol-426ab23e
|
|||
Filter result by event status (multiple option).
|
||||
Example: --filter-event-status=open --filter-event-status=closed
|
||||
|
||||
=item B<--filter-event-category>
|
||||
|
||||
Filter result by event category (multiple option).
|
||||
Example: --filter-event-category=issue
|
||||
|
||||
=item B<--display-affected-entities>
|
||||
|
||||
Display affected entities by the event.
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
|
|
Loading…
Reference in New Issue