diff --git a/apps/pvx/restapi/mode/httphits.pm b/apps/pvx/restapi/mode/httphits.pm index 8b62c0c6c..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(); @@ -126,7 +131,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..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(); @@ -135,7 +140,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..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(); @@ -170,7 +175,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..afe36432e 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}->{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(); } - + $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; }