(plugin) cloud::vmware::velocloud::restapi - fix empty return (#4476)

This commit is contained in:
qgarnier 2023-06-16 16:53:29 +02:00 committed by GitHub
parent cde60ceeb1
commit 17979bb7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 84 deletions

View File

@ -25,6 +25,24 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
sub prefix_edge_output {
my ($self, %options) = @_;
return "Edge '" . $options{instance_value}->{display} . "' ";
}
sub prefix_app_output {
my ($self, %options) = @_;
return "Application '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub long_output {
my ($self, %options) = @_;
return "Checking edge '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -86,24 +104,6 @@ sub set_counters {
]; ];
} }
sub prefix_edge_output {
my ($self, %options) = @_;
return "Edge '" . $options{instance_value}->{display} . "' ";
}
sub prefix_app_output {
my ($self, %options) = @_;
return "Application '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub long_output {
my ($self, %options) = @_;
return "Checking edge '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
@ -137,8 +137,12 @@ sub manage_selection {
next; next;
} }
$self->{edges}->{ $edge->{name} }->{id} = $edge->{id}; $self->{edges}->{ $edge->{name} } = {
$self->{edges}->{ $edge->{name} }->{display} = $edge->{name}; id => $edge->{id},
display => $edge->{name},
global => { app_count => 0 },
apps => {}
};
my $apps = $options{custom}->get_apps_metrics( my $apps = $options{custom}->get_apps_metrics(
edge_id => $edge->{id}, edge_id => $edge->{id},

View File

@ -25,6 +25,24 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
sub prefix_edge_output {
my ($self, %options) = @_;
return "Edge '" . $options{instance_value}->{display} . "' ";
}
sub prefix_category_output {
my ($self, %options) = @_;
return "Category '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub long_output {
my ($self, %options) = @_;
return "Checking edge '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -86,24 +104,6 @@ sub set_counters {
]; ];
} }
sub prefix_edge_output {
my ($self, %options) = @_;
return "Edge '" . $options{instance_value}->{display} . "' ";
}
sub prefix_category_output {
my ($self, %options) = @_;
return "Category '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub long_output {
my ($self, %options) = @_;
return "Checking edge '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
@ -137,8 +137,12 @@ sub manage_selection {
next; next;
} }
$self->{edges}->{$edge->{name}}->{id} = $edge->{id}; $self->{edges}->{ $edge->{name} } = {
$self->{edges}->{$edge->{name}}->{display} = $edge->{name}; id => $edge->{id},
display => $edge->{name},
global => { category_count => 0 },
categories => {}
};
my $categories = $options{custom}->get_categories_metrics( my $categories = $options{custom}->get_categories_metrics(
edge_id => $edge->{id}, edge_id => $edge->{id},
@ -160,7 +164,7 @@ sub manage_selection {
traffic_out => int($category->{bytesTx} * 8 / $self->{timeframe}), traffic_out => int($category->{bytesTx} * 8 / $self->{timeframe}),
traffic_in => int($category->{bytesRx} * 8 / $self->{timeframe}), traffic_in => int($category->{bytesRx} * 8 / $self->{timeframe}),
packets_out => $category->{packetsTx} / $self->{timeframe}, packets_out => $category->{packetsTx} / $self->{timeframe},
packets_in => $category->{packetsRx} / $self->{timeframe}, packets_in => $category->{packetsRx} / $self->{timeframe}
}; };
} }
} }

View File

@ -25,6 +25,24 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
sub prefix_edge_output {
my ($self, %options) = @_;
return "Edge '" . $options{instance_value}->{display} . "' ";
}
sub prefix_link_output {
my ($self, %options) = @_;
return "Link '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub long_output {
my ($self, %options) = @_;
return "Checking edge '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -102,24 +120,6 @@ sub set_counters {
]; ];
} }
sub prefix_edge_output {
my ($self, %options) = @_;
return "Edge '" . $options{instance_value}->{display} . "' ";
}
sub prefix_link_output {
my ($self, %options) = @_;
return "Link '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub long_output {
my ($self, %options) = @_;
return "Checking edge '" . $options{instance_value}->{display} . "' [Id: " . $options{instance_value}->{id} . "] ";
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
@ -146,15 +146,19 @@ sub manage_selection {
my $results = $options{custom}->list_edges(); my $results = $options{custom}->list_edges();
$self->{edges} = {}; $self->{edges} = {};
foreach my $edge (@{$results}) { foreach my $edge (@$results) {
if (defined($self->{option_results}->{filter_edge_name}) && $self->{option_results}->{filter_edge_name} ne '' && if (defined($self->{option_results}->{filter_edge_name}) && $self->{option_results}->{filter_edge_name} ne '' &&
$edge->{name} !~ /$self->{option_results}->{filter_edge_name}/) { $edge->{name} !~ /$self->{option_results}->{filter_edge_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $edge->{name} . "'.", debug => 1); $self->{output}->output_add(long_msg => "skipping '" . $edge->{name} . "'.", debug => 1);
next; next;
} }
$self->{edges}->{$edge->{name}}->{id} = $edge->{id}; $self->{edges}->{ $edge->{name} } = {
$self->{edges}->{$edge->{name}}->{display} = $edge->{name}; id => $edge->{id},
display => $edge->{name},
global => { link_count => 0 },
links => {}
};
my $links = $options{custom}->list_links( my $links = $options{custom}->list_links(
edge_id => $edge->{id}, edge_id => $edge->{id},

View File

@ -129,8 +129,12 @@ sub manage_selection {
next; next;
} }
$self->{edges}->{$edge->{name}}->{id} = $edge->{id}; $self->{edges}->{ $edge->{name} } = {
$self->{edges}->{$edge->{name}}->{display} = $edge->{name}; id => $edge->{id},
display => $edge->{name},
global => { link_count => 0 },
links => {}
};
my $links = $options{custom}->get_links_metrics( my $links = $options{custom}->get_links_metrics(
edge_id => $edge->{id}, edge_id => $edge->{id},

View File

@ -192,7 +192,7 @@ sub manage_selection {
$self->{edges}->{ $edge->{name} } = { $self->{edges}->{ $edge->{name} } = {
id => $edge->{id}, id => $edge->{id},
display => $edge->{name}, display => $edge->{name},
global => {}, global => { link_count => 0, traffic_in => 0, traffic_out => 0 },
links => {} links => {}
}; };