mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 23:54:18 +02:00
(plugin) cloud::vmware::velocloud::restapi - fix empty return (#4476)
This commit is contained in:
parent
cde60ceeb1
commit
17979bb7c0
@ -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},
|
||||||
@ -158,8 +162,8 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{app_count}++;
|
$self->{edges}->{ $edge->{name} }->{global}->{app_count}++;
|
||||||
$self->{edges}->{$edge->{name}}->{apps}->{ $app_name } = {
|
$self->{edges}->{ $edge->{name} }->{apps}->{ $app_name } = {
|
||||||
id => $app->{application},
|
id => $app->{application},
|
||||||
display => $app_name,
|
display => $app_name,
|
||||||
traffic_out => int($app->{bytesTx} * 8 / $self->{timeframe}),
|
traffic_out => int($app->{bytesTx} * 8 / $self->{timeframe}),
|
||||||
|
@ -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},
|
||||||
@ -153,14 +157,14 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{category_count}++;
|
$self->{edges}->{ $edge->{name} }->{global}->{category_count}++;
|
||||||
$self->{edges}->{$edge->{name}}->{categories}->{$category->{name}} = {
|
$self->{edges}->{ $edge->{name} }->{categories}->{$category->{name}} = {
|
||||||
id => $category->{category},
|
id => $category->{category},
|
||||||
display => $category->{name},
|
display => $category->{name},
|
||||||
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}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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},
|
||||||
@ -183,8 +187,8 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{link_count}++;
|
$self->{edges}->{ $edge->{name} }->{global}->{link_count}++;
|
||||||
$self->{edges}->{$edge->{name}}->{links}->{$link->{link}->{displayName}} = {
|
$self->{edges}->{ $edge->{name} }->{links}->{ $link->{link}->{displayName} } = {
|
||||||
id => $link->{linkId},
|
id => $link->{linkId},
|
||||||
display => $link->{link}->{displayName},
|
display => $link->{link}->{displayName},
|
||||||
voice => $qoes->{$link->{link}->{internalId}}->{score}->{0},
|
voice => $qoes->{$link->{link}->{internalId}}->{score}->{0},
|
||||||
@ -226,4 +230,4 @@ Can be: 'edge-links-count', 'qoe-voice-global', 'qoe-video-global', 'qoe-transac
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
@ -96,7 +96,7 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{edges}->{$edge->{id}} = {
|
$self->{edges}->{ $edge->{id} } = {
|
||||||
display => $edge->{name},
|
display => $edge->{name},
|
||||||
edge_state => $edge->{edgeState},
|
edge_state => $edge->{edgeState},
|
||||||
service_state => $edge->{serviceState},
|
service_state => $edge->{serviceState},
|
||||||
|
@ -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},
|
||||||
@ -144,8 +148,8 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{link_count}++;
|
$self->{edges}->{ $edge->{name} }->{global}->{link_count}++;
|
||||||
$self->{edges}->{$edge->{name}}->{links}->{$link->{link}->{displayName}} = {
|
$self->{edges}->{ $edge->{name} }->{links}->{ $link->{link}->{displayName} } = {
|
||||||
id => $link->{linkId},
|
id => $link->{linkId},
|
||||||
display => $link->{link}->{displayName},
|
display => $link->{link}->{displayName},
|
||||||
state => $link->{link}->{state},
|
state => $link->{link}->{state},
|
||||||
|
@ -189,10 +189,10 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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 => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -208,8 +208,8 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{link_count}++;
|
$self->{edges}->{ $edge->{name} }->{global}->{link_count}++;
|
||||||
$self->{edges}->{$edge->{name}}->{links}->{$link->{link}->{displayName}} = {
|
$self->{edges}->{ $edge->{name} }->{links}->{$link->{link}->{displayName}} = {
|
||||||
id => $link->{linkId},
|
id => $link->{linkId},
|
||||||
display => $link->{link}->{displayName},
|
display => $link->{link}->{displayName},
|
||||||
traffic_out => int($link->{bytesTx} * 8 / $self->{timeframe}),
|
traffic_out => int($link->{bytesTx} * 8 / $self->{timeframe}),
|
||||||
@ -221,12 +221,12 @@ sub manage_selection {
|
|||||||
packet_loss_out => $link->{bestLossPctTx},
|
packet_loss_out => $link->{bestLossPctTx},
|
||||||
packet_loss_in => $link->{bestLossPctRx}
|
packet_loss_in => $link->{bestLossPctRx}
|
||||||
};
|
};
|
||||||
if (!defined($self->{edges}->{$edge->{name}}->{global}->{traffic_in})) {
|
if (!defined($self->{edges}->{ $edge->{name} }->{global}->{traffic_in})) {
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{traffic_in} = 0;
|
$self->{edges}->{ $edge->{name} }->{global}->{traffic_in} = 0;
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{traffic_out} = 0;
|
$self->{edges}->{ $edge->{name} }->{global}->{traffic_out} = 0;
|
||||||
}
|
}
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{traffic_in} += (int($link->{bytesRx} * 8 / $self->{timeframe}));
|
$self->{edges}->{ $edge->{name} }->{global}->{traffic_in} += (int($link->{bytesRx} * 8 / $self->{timeframe}));
|
||||||
$self->{edges}->{$edge->{name}}->{global}->{traffic_out} += (int($link->{bytesTx} * 8 / $self->{timeframe}));
|
$self->{edges}->{ $edge->{name} }->{global}->{traffic_out} += (int($link->{bytesTx} * 8 / $self->{timeframe}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user