diff --git a/src/cloud/vmware/velocloud/restapi/mode/applicationusage.pm b/src/cloud/vmware/velocloud/restapi/mode/applicationusage.pm index 84cf574d4..c941db5a7 100644 --- a/src/cloud/vmware/velocloud/restapi/mode/applicationusage.pm +++ b/src/cloud/vmware/velocloud/restapi/mode/applicationusage.pm @@ -25,6 +25,24 @@ use base qw(centreon::plugins::templates::counter); use strict; 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 { 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 { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); @@ -137,8 +137,12 @@ sub manage_selection { next; } - $self->{edges}->{ $edge->{name} }->{id} = $edge->{id}; - $self->{edges}->{ $edge->{name} }->{display} = $edge->{name}; + $self->{edges}->{ $edge->{name} } = { + id => $edge->{id}, + display => $edge->{name}, + global => { app_count => 0 }, + apps => {} + }; my $apps = $options{custom}->get_apps_metrics( edge_id => $edge->{id}, @@ -158,8 +162,8 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{global}->{app_count}++; - $self->{edges}->{$edge->{name}}->{apps}->{ $app_name } = { + $self->{edges}->{ $edge->{name} }->{global}->{app_count}++; + $self->{edges}->{ $edge->{name} }->{apps}->{ $app_name } = { id => $app->{application}, display => $app_name, traffic_out => int($app->{bytesTx} * 8 / $self->{timeframe}), diff --git a/src/cloud/vmware/velocloud/restapi/mode/categoryusage.pm b/src/cloud/vmware/velocloud/restapi/mode/categoryusage.pm index 74d42a96b..1b45d6cbf 100644 --- a/src/cloud/vmware/velocloud/restapi/mode/categoryusage.pm +++ b/src/cloud/vmware/velocloud/restapi/mode/categoryusage.pm @@ -25,6 +25,24 @@ use base qw(centreon::plugins::templates::counter); use strict; 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 { 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 { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); @@ -137,8 +137,12 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{id} = $edge->{id}; - $self->{edges}->{$edge->{name}}->{display} = $edge->{name}; + $self->{edges}->{ $edge->{name} } = { + id => $edge->{id}, + display => $edge->{name}, + global => { category_count => 0 }, + categories => {} + }; my $categories = $options{custom}->get_categories_metrics( edge_id => $edge->{id}, @@ -153,14 +157,14 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{global}->{category_count}++; - $self->{edges}->{$edge->{name}}->{categories}->{$category->{name}} = { + $self->{edges}->{ $edge->{name} }->{global}->{category_count}++; + $self->{edges}->{ $edge->{name} }->{categories}->{$category->{name}} = { id => $category->{category}, display => $category->{name}, traffic_out => int($category->{bytesTx} * 8 / $self->{timeframe}), traffic_in => int($category->{bytesRx} * 8 / $self->{timeframe}), packets_out => $category->{packetsTx} / $self->{timeframe}, - packets_in => $category->{packetsRx} / $self->{timeframe}, + packets_in => $category->{packetsRx} / $self->{timeframe} }; } } diff --git a/src/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm b/src/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm index 4c7743c1d..1357714dd 100644 --- a/src/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm +++ b/src/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm @@ -25,6 +25,24 @@ use base qw(centreon::plugins::templates::counter); use strict; 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 { 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 { my ($class, %options) = @_; 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(); $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 '' && $edge->{name} !~ /$self->{option_results}->{filter_edge_name}/) { $self->{output}->output_add(long_msg => "skipping '" . $edge->{name} . "'.", debug => 1); next; } - - $self->{edges}->{$edge->{name}}->{id} = $edge->{id}; - $self->{edges}->{$edge->{name}}->{display} = $edge->{name}; + + $self->{edges}->{ $edge->{name} } = { + id => $edge->{id}, + display => $edge->{name}, + global => { link_count => 0 }, + links => {} + }; my $links = $options{custom}->list_links( edge_id => $edge->{id}, @@ -183,8 +187,8 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{global}->{link_count}++; - $self->{edges}->{$edge->{name}}->{links}->{$link->{link}->{displayName}} = { + $self->{edges}->{ $edge->{name} }->{global}->{link_count}++; + $self->{edges}->{ $edge->{name} }->{links}->{ $link->{link}->{displayName} } = { id => $link->{linkId}, display => $link->{link}->{displayName}, 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 -=cut \ No newline at end of file +=cut diff --git a/src/cloud/vmware/velocloud/restapi/mode/edgestatus.pm b/src/cloud/vmware/velocloud/restapi/mode/edgestatus.pm index bcc8c6cf6..57b4c4ad2 100644 --- a/src/cloud/vmware/velocloud/restapi/mode/edgestatus.pm +++ b/src/cloud/vmware/velocloud/restapi/mode/edgestatus.pm @@ -96,7 +96,7 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{id}} = { + $self->{edges}->{ $edge->{id} } = { display => $edge->{name}, edge_state => $edge->{edgeState}, service_state => $edge->{serviceState}, diff --git a/src/cloud/vmware/velocloud/restapi/mode/linkstatus.pm b/src/cloud/vmware/velocloud/restapi/mode/linkstatus.pm index cd5b9193e..5567affbd 100644 --- a/src/cloud/vmware/velocloud/restapi/mode/linkstatus.pm +++ b/src/cloud/vmware/velocloud/restapi/mode/linkstatus.pm @@ -129,8 +129,12 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{id} = $edge->{id}; - $self->{edges}->{$edge->{name}}->{display} = $edge->{name}; + $self->{edges}->{ $edge->{name} } = { + id => $edge->{id}, + display => $edge->{name}, + global => { link_count => 0 }, + links => {} + }; my $links = $options{custom}->get_links_metrics( edge_id => $edge->{id}, @@ -144,8 +148,8 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{global}->{link_count}++; - $self->{edges}->{$edge->{name}}->{links}->{$link->{link}->{displayName}} = { + $self->{edges}->{ $edge->{name} }->{global}->{link_count}++; + $self->{edges}->{ $edge->{name} }->{links}->{ $link->{link}->{displayName} } = { id => $link->{linkId}, display => $link->{link}->{displayName}, state => $link->{link}->{state}, diff --git a/src/cloud/vmware/velocloud/restapi/mode/linkusage.pm b/src/cloud/vmware/velocloud/restapi/mode/linkusage.pm index 43ffe5f25..f4e500edf 100644 --- a/src/cloud/vmware/velocloud/restapi/mode/linkusage.pm +++ b/src/cloud/vmware/velocloud/restapi/mode/linkusage.pm @@ -189,10 +189,10 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}} = { + $self->{edges}->{ $edge->{name} } = { id => $edge->{id}, display => $edge->{name}, - global => {}, + global => { link_count => 0, traffic_in => 0, traffic_out => 0 }, links => {} }; @@ -208,8 +208,8 @@ sub manage_selection { next; } - $self->{edges}->{$edge->{name}}->{global}->{link_count}++; - $self->{edges}->{$edge->{name}}->{links}->{$link->{link}->{displayName}} = { + $self->{edges}->{ $edge->{name} }->{global}->{link_count}++; + $self->{edges}->{ $edge->{name} }->{links}->{$link->{link}->{displayName}} = { id => $link->{linkId}, display => $link->{link}->{displayName}, traffic_out => int($link->{bytesTx} * 8 / $self->{timeframe}), @@ -221,12 +221,12 @@ sub manage_selection { packet_loss_out => $link->{bestLossPctTx}, packet_loss_in => $link->{bestLossPctRx} }; - if (!defined($self->{edges}->{$edge->{name}}->{global}->{traffic_in})) { - $self->{edges}->{$edge->{name}}->{global}->{traffic_in} = 0; - $self->{edges}->{$edge->{name}}->{global}->{traffic_out} = 0; + if (!defined($self->{edges}->{ $edge->{name} }->{global}->{traffic_in})) { + $self->{edges}->{ $edge->{name} }->{global}->{traffic_in} = 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_out} += (int($link->{bytesTx} * 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})); } }