diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/custom/api.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/custom/api.pm index cb0999ebc..7bede55b5 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/custom/api.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/custom/api.pm @@ -209,14 +209,13 @@ sub request_api { $self->{output}->option_exit(); } - $self->{output}->output_add(long_msg => "URL: '" . $self->{proto} . '://' . $self->{hostname} . ':' . - $self->{port} . $self->{api_path} . $options{path} . "'", debug => 1); - my $content = $self->{http}->request( method => $options{method}, url_path => $self->{api_path} . $options{path}, query_form_post => $encoded_form_post, - critical_status => '', warning_status => '', unknown_status => '' + critical_status => '', + warning_status => '', + unknown_status => '' ); my $decoded; @@ -270,7 +269,7 @@ sub list_links { metrics => [ 'bytesRx' ], interval => { start => $start_time - }, + } } ); @@ -296,7 +295,25 @@ sub get_links_metrics { 'bestLatencyMsRx', 'bestLatencyMsTx', 'bestLossPctRx', 'bestLossPctTx' ], interval => { start => $start_time - }, + } + } + ); + + return $results; +} + +sub get_identifiable_applications { + my ($self, %options) = @_; + + if (!defined($self->{entreprise_id})) { + $self->get_entreprise_id(); + } + + my $results = $self->request_api( + method => 'POST', + path => '/configuration/getIdentifiableApplications', + query_form_post => { + enterpriseId => $self->{entreprise_id} } ); @@ -317,7 +334,7 @@ sub get_apps_metrics { metrics => [ 'bytesRx', 'bytesTx', 'packetsRx', 'packetsTx' ], interval => { start => $start_time - }, + } } ); @@ -360,7 +377,7 @@ sub get_categories_metrics { metrics => [ 'bytesRx', 'bytesTx', 'packetsRx', 'packetsTx' ], interval => { start => $start_time - }, + } } ); diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/applicationusage.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/applicationusage.pm index 6ee4f7d92..792c6c93d 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/applicationusage.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/applicationusage.pm @@ -33,7 +33,7 @@ sub set_counters { message_multiple => 'All edges applications usage are ok', indent_long_output => ' ', group => [ { name => 'apps', display_long => 1, cb_prefix_output => 'prefix_app_output', - message_multiple => 'All applications usage are ok', type => 1 }, + message_multiple => 'All applications usage are ok', type => 1 } ] } ]; @@ -44,9 +44,8 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { value => 'traffic_in', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'traffic-out', nlabel => 'application.traffic.out.bitspersecond', set => { @@ -54,29 +53,26 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { value => 'traffic_out', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'packets-in', nlabel => 'application.packets.in.persecond', set => { key_values => [ { name => 'packets_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets In: %.2f packets/s', perfdatas => [ - { value => 'packets_in', template => '%.2f', - min => 0, unit => 'packets/s', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 } + ] } }, { label => 'packets-out', nlabel => 'application.packets.out.persecond', set => { key_values => [ { name => 'packets_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets Out: %.2f packets/s', perfdatas => [ - { value => 'packets_out', template => '%.2f', - min => 0, unit => 'packets/s', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 } + ] } - }, + } ]; } @@ -105,9 +101,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-edge-name:s' => { name => 'filter_edge_name' }, - 'filter-application-name:s' => { name => 'filter_application_name' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '' }, + 'filter-application-name:s' => { name => 'filter_application_name' } }); return $self; @@ -118,14 +112,13 @@ sub check_options { $self->SUPER::check_options(%options); $self->{timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - - $self->change_macros(macros => ['warning_status', 'critical_status']); } sub manage_selection { my ($self, %options) = @_; - my $results = $options{custom}->list_edges; + my $results = $options{custom}->list_edges(); + my $config_applications = $options{custom}->get_identifiable_applications(); $self->{edges} = {}; foreach my $edge (@{$results}) { @@ -135,8 +128,8 @@ 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}; + $self->{edges}->{ $edge->{name} }->{display} = $edge->{name}; my $apps = $options{custom}->get_apps_metrics( edge_id => $edge->{id}, @@ -144,20 +137,28 @@ sub manage_selection { ); foreach my $app (@{$apps}) { + my $app_name = $app->{application}; + foreach (@{$config_applications->{applications}}) { + if ($_->{id} eq $app_name) { + $app_name = $_->{name}; + last; + } + } + if (defined($self->{option_results}->{filter_application_name}) && $self->{option_results}->{filter_application_name} ne '' && - $app->{name} !~ /$self->{option_results}->{filter_application_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $edge->{id} . "'.", debug => 1); + $app_name !~ /$self->{option_results}->{filter_application_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $app_names . "'.", debug => 1); next; } - $self->{edges}->{$edge->{name}}->{apps}->{$app->{name}} = { + $self->{edges}->{$edge->{name}}->{apps}->{ $app_name } = { id => $app->{application}, - display => $app->{name}, + display => $app_name, traffic_out => int($app->{bytesTx} * 8 / $self->{timeframe}), traffic_in => int($app->{bytesRx} * 8 / $self->{timeframe}), packets_out => $app->{packetsTx} / $self->{timeframe}, - packets_in => $app->{packetsRx} / $self->{timeframe}, + packets_in => $app->{packetsRx} / $self->{timeframe} }; } } diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/categoryusage.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/categoryusage.pm index 6759143d7..6f66efa3f 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/categoryusage.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/categoryusage.pm @@ -33,7 +33,7 @@ sub set_counters { message_multiple => 'All edges categories usage are ok', indent_long_output => ' ', group => [ { name => 'categories', display_long => 1, cb_prefix_output => 'prefix_category_output', - message_multiple => 'All categories usage are ok', type => 1 }, + message_multiple => 'All categories usage are ok', type => 1 } ] } ]; @@ -44,9 +44,8 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { value => 'traffic_in', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'traffic-out', nlabel => 'category.traffic.out.bitspersecond', set => { @@ -54,29 +53,26 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { value => 'traffic_out', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'packets-in', nlabel => 'category.packets.in.persecond', set => { key_values => [ { name => 'packets_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets In: %.2f packets/s', perfdatas => [ - { value => 'packets_in', template => '%.2f', - min => 0, unit => 'packets/s', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 } + ] } }, { label => 'packets-out', nlabel => 'category.packets.out.persecond', set => { key_values => [ { name => 'packets_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets Out: %.2f packets/s', perfdatas => [ - { value => 'packets_out', template => '%.2f', - min => 0, unit => 'packets/s', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 } + ] } - }, + } ]; } @@ -105,9 +101,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-edge-name:s' => { name => 'filter_edge_name' }, - 'filter-category-name:s' => { name => 'filter_category_name' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '' }, + 'filter-category-name:s' => { name => 'filter_category_name' } }); return $self; @@ -118,14 +112,12 @@ sub check_options { $self->SUPER::check_options(%options); $self->{timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - - $self->change_macros(macros => ['warning_status', 'critical_status']); } sub manage_selection { my ($self, %options) = @_; - my $results = $options{custom}->list_edges; + my $results = $options{custom}->list_edges(); $self->{edges} = {}; foreach my $edge (@{$results}) { @@ -147,7 +139,7 @@ sub manage_selection { if (defined($self->{option_results}->{filter_category_name}) && $self->{option_results}->{filter_category_name} ne '' && $category->{name} !~ /$self->{option_results}->{filter_category_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $edge->{id} . "'.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $category->{name} . "'.", debug => 1); next; } diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm index 70a62d2bc..b5da1a275 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm @@ -34,7 +34,7 @@ sub set_counters { group => [ { name => 'global', type => 0 }, { name => 'links', display_long => 1, cb_prefix_output => 'prefix_link_output', - message_multiple => 'All links QOE are ok', type => 1 }, + message_multiple => 'All links QOE are ok', type => 1 } ] } ]; @@ -44,29 +44,26 @@ sub set_counters { key_values => [ { name => 'voice' } ], output_template => 'Global voice QOE: %s', perfdatas => [ - { value => 'voice', template => '%s', - min => 0, max => 10, label_extra_instance => 1 }, - ], + { template => '%s', min => 0, max => 10, label_extra_instance => 1 } + ] } }, { label => 'qoe-video-global', nlabel => 'global.qoe.video.count', set => { key_values => [ { name => 'video' } ], output_template => 'Global video QOE: %s', perfdatas => [ - { value => 'video', template => '%s', - min => 0, max => 10, label_extra_instance => 1 }, - ], + { template => '%s', min => 0, max => 10, label_extra_instance => 1 } + ] } }, { label => 'qoe-transactional-global', nlabel => 'global.qoe.transactional.count', set => { key_values => [ { name => 'transactional' } ], output_template => 'Global transactional QOE: %s', perfdatas => [ - { value => 'transactional', template => '%s', - min => 0, max => 10, label_extra_instance => 1 }, - ], + { template => '%s', min => 0, max => 10, label_extra_instance => 1 } + ] } - }, + } ]; $self->{maps_counters}->{links} = [ @@ -74,27 +71,24 @@ sub set_counters { key_values => [ { name => 'voice' }, { name => 'display' }, { name => 'id' } ], output_template => 'Voice QOE: %s', perfdatas => [ - { value => 'voice', template => '%s', - min => 0, max => 10, label_extra_instance => 1 }, - ], + { template => '%s', min => 0, max => 10, label_extra_instance => 1 } + ] } }, { label => 'qoe-video', nlabel => 'link.qoe.video.count', set => { key_values => [ { name => 'video' }, { name => 'display' }, { name => 'id' } ], output_template => 'Video QOE: %s', perfdatas => [ - { value => 'video', template => '%s', - min => 0, max => 10, label_extra_instance => 1 }, - ], + { template => '%s', min => 0, max => 10, label_extra_instance => 1 } + ] } }, { label => 'qoe-transactional', nlabel => 'link.qoe.transactional.count', set => { key_values => [ { name => 'transactional' }, { name => 'display' }, { name => 'id' } ], output_template => 'Transactional QOE: %s', perfdatas => [ - { value => 'transactional', template => '%s', - min => 0, max => 10, label_extra_instance => 1 }, - ], + { template => '%s', min => 0, max => 10, label_extra_instance => 1 } + ] } }, ]; @@ -125,7 +119,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-edge-name:s' => { name => 'filter_edge_name' }, - 'filter-link-name:s' => { name => 'filter_link_name' }, + 'filter-link-name:s' => { name => 'filter_link_name' } }); return $self; @@ -136,13 +130,12 @@ sub check_options { $self->SUPER::check_options(%options); $self->{timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - $self->change_macros(macros => ['warning_status', 'critical_status']); } sub manage_selection { my ($self, %options) = @_; - my $results = $options{custom}->list_edges; + my $results = $options{custom}->list_edges(); $self->{edges} = {}; foreach my $edge (@{$results}) { @@ -170,7 +163,7 @@ sub manage_selection { $self->{edges}->{$edge->{name}}->{global} = { voice => $qoes->{overallLinkQuality}->{score}->{0}, video => $qoes->{overallLinkQuality}->{score}->{1}, - transactional => $qoes->{overallLinkQuality}->{score}->{2}, + transactional => $qoes->{overallLinkQuality}->{score}->{2} }; foreach my $link (@{$links}) { @@ -187,7 +180,7 @@ sub manage_selection { display => $link->{link}->{displayName}, voice => $qoes->{$link->{link}->{internalId}}->{score}->{0}, video => $qoes->{$link->{link}->{internalId}}->{score}->{1}, - transactional => $qoes->{$link->{link}->{internalId}}->{score}->{2}, + transactional => $qoes->{$link->{link}->{internalId}}->{score}->{2} }; } } diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgestatus.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgestatus.pm index c6fa7a1e1..bfc1f163d 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgestatus.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/edgestatus.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_status_output { my ($self, %options) = @_; @@ -38,17 +38,6 @@ sub custom_status_output { ); } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{edge_state} = $options{new_datas}->{$self->{instance} . '_edge_state'}; - $self->{result_values}->{service_state} = $options{new_datas}->{$self->{instance} . '_service_state'}; - $self->{result_values}->{ha_state} = $options{new_datas}->{$self->{instance} . '_ha_state'}; - $self->{result_values}->{activation_state} = $options{new_datas}->{$self->{instance} . '_activation_state'}; - - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -58,15 +47,21 @@ sub set_counters { ]; $self->{maps_counters}->{edges} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'edge_state' }, { name => 'service_state' }, { name => 'ha_state' }, - { name => 'activation_state' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), + { + label => 'status', + type => 2, + unknown_default => '%{edge_state} =~ /NEVER_ACTIVATED/', + critical_default => '%{edge_state} !~ /CONNECTED/ && %{edge_state} !~ /NEVER_ACTIVATED/', + set => { + key_values => [ + { name => 'edge_state' }, { name => 'service_state' }, { name => 'ha_state' }, + { name => 'activation_state' }, { name => 'display' } + ], closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; } @@ -82,26 +77,16 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - 'unknown-status:s' => { name => 'unknown_status', default => '%{edge_state} =~ /NEVER_ACTIVATED/' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{edge_state} !~ /CONNECTED/ && %{edge_state} !~ /NEVER_ACTIVATED/' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); -} - sub manage_selection { my ($self, %options) = @_; - my $results = $options{custom}->list_edges; + my $results = $options{custom}->list_edges(); $self->{edges} = {}; foreach my $edge (@{$results}) { diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkstatus.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkstatus.pm index 59f26f082..e747c1b53 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkstatus.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkstatus.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_status_output { my ($self, %options) = @_; @@ -45,21 +45,26 @@ sub set_counters { message_multiple => 'All edges links status are ok', indent_long_output => ' ', group => [ { name => 'links', display_long => 1, cb_prefix_output => 'prefix_link_output', - message_multiple => 'All links status are ok', type => 1 }, + message_multiple => 'All links status are ok', type => 1 } ] } ]; $self->{maps_counters}->{links} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'state' }, { name => 'vpn_state' }, { name => 'backup_state' }, - { name => 'display' }, { name => 'id' } ], - closure_custom_calc => \&catalog_status_calc, + { + label => 'status', + type => 2, + critical_default => '%{state} !~ /STABLE/ || %{vpn_state} !~ /STABLE/', + set => { + key_values => [ + { name => 'state' }, { name => 'vpn_state' }, { name => 'backup_state' }, + { name => 'display' }, { name => 'id' } + ], closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } - }, + } ]; } @@ -88,10 +93,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-edge-name:s' => { name => 'filter_edge_name' }, - 'filter-link-name:s' => { name => 'filter_link_name' }, - 'unknown-status:s' => { name => 'unknown_status', default => '' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /STABLE/ || %{vpn_state} !~ /STABLE/' }, + 'filter-link-name:s' => { name => 'filter_link_name' } }); return $self; @@ -102,14 +104,12 @@ sub check_options { $self->SUPER::check_options(%options); $self->{timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - - $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); } sub manage_selection { my ($self, %options) = @_; - my $results = $options{custom}->list_edges; + my $results = $options{custom}->list_edges(); $self->{edges} = {}; foreach my $edge (@{$results}) { diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkusage.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkusage.pm index b662014f1..b8bc87b64 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkusage.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/linkusage.pm @@ -34,7 +34,7 @@ sub set_counters { group => [ { name => 'global', cb_prefix_output => 'prefix_global_output', type => 0, skipped_code => { -10 => 1 } }, { name => 'links', display_long => 1, cb_prefix_output => 'prefix_link_output', - message_multiple => 'All links status are ok', type => 1 }, + message_multiple => 'All links status are ok', type => 1 } ] } ]; @@ -45,9 +45,8 @@ sub set_counters { output_template => 'Total Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'links-traffic-out', nlabel => 'links.traffic.out.bitspersecond', set => { @@ -55,9 +54,8 @@ sub set_counters { output_template => 'Total Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } } ]; @@ -68,9 +66,8 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { value => 'traffic_in', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'traffic-out', nlabel => 'link.traffic.out.bitspersecond', set => { @@ -78,65 +75,58 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { value => 'traffic_out', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1 }, - ], + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 } + ] } }, { label => 'latency-in', nlabel => 'link.latency.in.milliseconds', set => { key_values => [ { name => 'latency_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Latency In: %.2f ms', perfdatas => [ - { value => 'latency_in', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 } + ] } }, { label => 'latency-out', nlabel => 'link.latency.out.milliseconds', set => { key_values => [ { name => 'latency_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Latency Out: %.2f ms', perfdatas => [ - { value => 'latency_out', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 } + ] } }, { label => 'jitter-in', nlabel => 'link.jitter.in.milliseconds', set => { key_values => [ { name => 'jitter_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Jitter In: %.2f ms', perfdatas => [ - { value => 'jitter_in', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 } + ] } }, { label => 'jitter-out', nlabel => 'link.jitter.out.milliseconds', set => { key_values => [ { name => 'jitter_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Jitter Out: %.2f ms', perfdatas => [ - { value => 'jitter_out', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 } + ] } }, { label => 'packet-loss-in', nlabel => 'link.packet.loss.in.percentage', set => { key_values => [ { name => 'packet_loss_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packet Loss In: %.2f%%', perfdatas => [ - { value => 'packet_loss_in', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, { label => 'packet-loss-out', nlabel => 'link.packet.loss.out.percentage', set => { key_values => [ { name => 'packet_loss_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packet Loss Out: %.2f%%', perfdatas => [ - { value => 'packet_loss_out', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1 }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } - }, + } ]; } @@ -165,7 +155,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-edge-name:s' => { name => 'filter_edge_name' }, - 'filter-link-name:s' => { name => 'filter_link_name' }, + 'filter-link-name:s' => { name => 'filter_link_name' } }); return $self; @@ -176,8 +166,6 @@ sub check_options { $self->SUPER::check_options(%options); $self->{timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; - - $self->change_macros(macros => ['warning_status', 'critical_status']); } sub manage_selection { @@ -222,7 +210,7 @@ sub manage_selection { jitter_out => $link->{bestJitterMsTx}, jitter_in => $link->{bestJitterMsRx}, packet_loss_out => $link->{bestLossPctTx}, - packet_loss_in => $link->{bestLossPctRx}, + packet_loss_in => $link->{bestLossPctRx} }; if (!defined($self->{edges}->{$edge->{name}}->{global}->{traffic_in})) { $self->{edges}->{$edge->{name}}->{global}->{traffic_in} = 0; diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/listlinks.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/listlinks.pm index cf7e40797..72d93a576 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/mode/listlinks.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/mode/listlinks.pm @@ -31,7 +31,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-edge-name:s' => { name => 'filter_edge_name' }, + 'filter-edge-name:s' => { name => 'filter_edge_name' } }); return $self; @@ -45,7 +45,7 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $edges = $options{custom}->list_edges; + my $edges = $options{custom}->list_edges(); foreach my $edge (@{$edges}) { if (defined($self->{option_results}->{filter_edge_name}) && $self->{option_results}->{filter_edge_name} ne '' && $edge->{name} !~ /$self->{option_results}->{filter_edge_name}/) { diff --git a/centreon-plugins/cloud/vmware/velocloud/restapi/plugin.pm b/centreon-plugins/cloud/vmware/velocloud/restapi/plugin.pm index 338be2656..5adffe276 100644 --- a/centreon-plugins/cloud/vmware/velocloud/restapi/plugin.pm +++ b/centreon-plugins/cloud/vmware/velocloud/restapi/plugin.pm @@ -30,7 +30,7 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( + $self->{modes} = { 'application-usage' => 'cloud::vmware::velocloud::restapi::mode::applicationusage', 'category-usage' => 'cloud::vmware::velocloud::restapi::mode::categoryusage', 'discovery' => 'cloud::vmware::velocloud::restapi::mode::discovery', @@ -39,10 +39,10 @@ sub new { 'link-status' => 'cloud::vmware::velocloud::restapi::mode::linkstatus', 'link-usage' => 'cloud::vmware::velocloud::restapi::mode::linkusage', 'list-edges' => 'cloud::vmware::velocloud::restapi::mode::listedges', - 'list-links' => 'cloud::vmware::velocloud::restapi::mode::listlinks', - ); + 'list-links' => 'cloud::vmware::velocloud::restapi::mode::listlinks' + }; - $self->{custom_modes}{api} = 'cloud::vmware::velocloud::restapi::custom::api'; + $self->{custom_modes}->{api} = 'cloud::vmware::velocloud::restapi::custom::api'; return $self; }