From e44bd9ecfeca2f900346941dc6a4f30848dec905 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Tue, 26 May 2020 09:26:26 +0200 Subject: [PATCH 1/2] fix(plugin) pvx compat with last API --- apps/pvx/restapi/mode/httphits.pm | 2 +- apps/pvx/restapi/mode/networkconnection.pm | 2 +- apps/pvx/restapi/mode/networktraffic.pm | 2 +- apps/pvx/restapi/mode/networkuserexperience.pm | 12 ++++++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/pvx/restapi/mode/httphits.pm b/apps/pvx/restapi/mode/httphits.pm index 8b62c0c6c..fd49502a3 100644 --- a/apps/pvx/restapi/mode/httphits.pm +++ b/apps/pvx/restapi/mode/httphits.pm @@ -126,7 +126,7 @@ sub manage_selection { $instance = ${$result->{key}}[0]->{value} if (defined(${$result->{key}}[0]->{value})); $instance = ${$result->{key}}[0]->{status} if (defined(${$result->{key}}[0]->{status})); $self->{instances}->{$instance}->{key} = $instance; - $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if ($self->{option_results}->{instance} =~ /application/); + $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if (defined($apps->{$instance}->{name}) && $self->{option_results}->{instance} =~ /application/); $self->{instances}->{$instance}->{error_hits} = (defined(${$result->{values}}[0]->{value})) ? ${$result->{values}}[0]->{value} / $self->{pvql_timeframe} : 0; $self->{instances}->{$instance}->{hits} = ${$result->{values}}[1]->{value} / $self->{pvql_timeframe}; $self->{instances}->{$instance}->{ratio} = (defined(${$result->{values}}[0]->{value})) ? ${$result->{values}}[1]->{value} / (${$result->{values}}[0]->{value} + ${$result->{values}}[1]->{value}) : 1; diff --git a/apps/pvx/restapi/mode/networkconnection.pm b/apps/pvx/restapi/mode/networkconnection.pm index 4c8da8f69..c0692da69 100644 --- a/apps/pvx/restapi/mode/networkconnection.pm +++ b/apps/pvx/restapi/mode/networkconnection.pm @@ -135,7 +135,7 @@ sub manage_selection { $instance = ${$result->{key}}[0]->{value} if (defined(${$result->{key}}[0]->{value})); $instance = ${$result->{key}}[0]->{status} if (defined(${$result->{key}}[0]->{status})); $self->{instances}->{$instance}->{key} = $instance; - $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if ($self->{option_results}->{instance} =~ /application/); + $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if (defined($apps->{$instance}->{name}) && $self->{option_results}->{instance} =~ /application/); $self->{instances}->{$instance}->{syns_ratio} = (defined(${$result->{values}}[0]->{value})) ? ${$result->{values}}[0]->{value} : 1; $self->{instances}->{$instance}->{syns} = ${$result->{values}}[1]->{value} / $self->{pvql_timeframe}; $self->{instances}->{$instance}->{ct_count} = ${$result->{values}}[2]->{value} / $self->{pvql_timeframe}; diff --git a/apps/pvx/restapi/mode/networktraffic.pm b/apps/pvx/restapi/mode/networktraffic.pm index 26b045e12..aecdbda04 100644 --- a/apps/pvx/restapi/mode/networktraffic.pm +++ b/apps/pvx/restapi/mode/networktraffic.pm @@ -170,7 +170,7 @@ sub manage_selection { $instance = ${$result->{key}}[0]->{value} if (defined(${$result->{key}}[0]->{value})); $instance = ${$result->{key}}[0]->{status} if (defined(${$result->{key}}[0]->{status})); $self->{instances}->{$instance}->{key} = $instance; - $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if ($self->{option_results}->{instance} =~ /application/); + $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if (defined($apps->{$instance}->{name}) && $self->{option_results}->{instance} =~ /application/); $self->{instances}->{$instance}->{traffic} = ${$result->{values}}[0]->{value} * 8 / $self->{pvql_timeframe}; $self->{instances}->{$instance}->{server_traffic} = ${$result->{values}}[1]->{value} * 8 / $self->{pvql_timeframe}; $self->{instances}->{$instance}->{client_traffic} = ${$result->{values}}[2]->{value} * 8 / $self->{pvql_timeframe}; diff --git a/apps/pvx/restapi/mode/networkuserexperience.pm b/apps/pvx/restapi/mode/networkuserexperience.pm index 6bad42c0b..6110bbfbc 100644 --- a/apps/pvx/restapi/mode/networkuserexperience.pm +++ b/apps/pvx/restapi/mode/networkuserexperience.pm @@ -70,11 +70,16 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - if (!defined($self->{option_results}->{instance}) || $self->{option_results}->{instance} eq '') { - $self->{output}->add_option_msg(short_msg => "Need to specify --instance option as a PVQL object."); + if (!defined($self->{option_results}->{from}) || $self->{option_results}->{from} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --from option as a PVQL object."); $self->{output}->option_exit(); } + if (!defined($self->{option_results}->{from}) || $self->{option_results}->{instance} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --instance option as a PVQL object."); + $self->{output}->option_exit(); + } + $self->{pvql_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; } @@ -86,7 +91,6 @@ sub manage_selection { $instance_label =~ s/(\w+)/\u\L$1/g; $self->{instances} = {}; - my $apps; if ($self->{option_results}->{instance} =~ /application/) { my $results = $options{custom}->get_endpoint(url_path => '/get-configuration'); @@ -108,7 +112,7 @@ sub manage_selection { $instance = ${$result->{key}}[0]->{value} if (defined(${$result->{key}}[0]->{value})); $instance = ${$result->{key}}[0]->{status} if (defined(${$result->{key}}[0]->{status})); $self->{instances}->{$instance}->{key} = $instance; - $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if ($self->{option_results}->{instance} =~ /application/); + $self->{instances}->{$instance}->{key} = $apps->{$instance}->{name} if (defined($apps->{$instance}->{name}) && $self->{option_results}->{instance} =~ /application/); $self->{instances}->{$instance}->{user_experience} = (defined(${$result->{values}}[0]->{value})) ? ${$result->{values}}[0]->{value} : 0; $self->{instances}->{$instance}->{instance_label} = $instance_label; } From 00a586629695f55b9af5839c7b25ab943f71feb7 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Tue, 26 May 2020 09:34:58 +0200 Subject: [PATCH 2/2] fix(pvx)compat-with-last-api(2) (#2014) --- apps/pvx/restapi/mode/httphits.pm | 5 +++++ apps/pvx/restapi/mode/networkconnection.pm | 5 +++++ apps/pvx/restapi/mode/networktraffic.pm | 5 +++++ apps/pvx/restapi/mode/networkuserexperience.pm | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/pvx/restapi/mode/httphits.pm b/apps/pvx/restapi/mode/httphits.pm index fd49502a3..16e1b99b0 100644 --- a/apps/pvx/restapi/mode/httphits.pm +++ b/apps/pvx/restapi/mode/httphits.pm @@ -88,6 +88,11 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); + if (!defined($self->{option_results}->{from}) || $self->{option_results}->{from} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --from option as a PVQL object."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{instance}) || $self->{option_results}->{instance} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --instance option as a PVQL object."); $self->{output}->option_exit(); diff --git a/apps/pvx/restapi/mode/networkconnection.pm b/apps/pvx/restapi/mode/networkconnection.pm index c0692da69..792005e08 100644 --- a/apps/pvx/restapi/mode/networkconnection.pm +++ b/apps/pvx/restapi/mode/networkconnection.pm @@ -97,6 +97,11 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); + if (!defined($self->{option_results}->{from}) || $self->{option_results}->{from} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --from option as a PVQL object."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{instance}) || $self->{option_results}->{instance} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --instance option as a PVQL object."); $self->{output}->option_exit(); diff --git a/apps/pvx/restapi/mode/networktraffic.pm b/apps/pvx/restapi/mode/networktraffic.pm index aecdbda04..41ec25d51 100644 --- a/apps/pvx/restapi/mode/networktraffic.pm +++ b/apps/pvx/restapi/mode/networktraffic.pm @@ -132,6 +132,11 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); + if (!defined($self->{option_results}->{from}) || $self->{option_results}->{from} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --from option as a PVQL object."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{instance}) || $self->{option_results}->{instance} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --instance option as a PVQL object."); $self->{output}->option_exit(); diff --git a/apps/pvx/restapi/mode/networkuserexperience.pm b/apps/pvx/restapi/mode/networkuserexperience.pm index 6110bbfbc..afe36432e 100644 --- a/apps/pvx/restapi/mode/networkuserexperience.pm +++ b/apps/pvx/restapi/mode/networkuserexperience.pm @@ -75,7 +75,7 @@ sub check_options { $self->{output}->option_exit(); } - if (!defined($self->{option_results}->{from}) || $self->{option_results}->{instance} eq '') { + if (!defined($self->{option_results}->{instance}) || $self->{option_results}->{instance} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --instance option as a PVQL object."); $self->{output}->option_exit(); }