+ change filter options on citrix

This commit is contained in:
garnier-quentin 2017-03-09 11:37:40 +01:00
parent bd63481afc
commit ebf489476f
1 changed files with 12 additions and 26 deletions

View File

@ -121,8 +121,7 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"name:s" => { name => 'name' }, "filter-name:s" => { name => 'filter_name' },
"regexp" => { name => 'use_regexp' },
"filter-type:s" => { name => 'filter_type' }, "filter-type:s" => { name => 'filter_type' },
"threshold-overload:s@" => { name => 'threshold_overload' }, "threshold-overload:s@" => { name => 'threshold_overload' },
}); });
@ -149,16 +148,6 @@ sub check_options {
} }
} }
sub add_result {
my ($self, %options) = @_;
$self->{vservers}->{$options{instance}} = {
display => $options{result}->{vsvrName},
health => $options{result}->{vsvrHealth},
state => $options{result}->{vsvrState},
};
}
my %map_vs_type = ( my %map_vs_type = (
0 => 'unknown', 0 => 'unknown',
1 => 'loadbalancing', 1 => 'loadbalancing',
@ -205,16 +194,17 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "skipping Virtual Server '" . $result->{vsvrName} . "'.", debug => 1); $self->{output}->output_add(long_msg => "skipping Virtual Server '" . $result->{vsvrName} . "'.", debug => 1);
next; next;
} }
if (!defined($self->{option_results}->{name})) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$self->add_result(instance => $instance, result => $result); $result->{vsvrName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping Virtual Server '" . $result->{vsvrName} . "'.", debug => 1);
next; next;
} }
if (!defined($self->{option_results}->{use_regexp}) && $result->{vsvrName} eq $self->{option_results}->{name}) {
$self->add_result(instance => $instance, result => $result); $self->{vservers}->{$options{instance}} = {
} display => $options{result}->{vsvrName},
if (defined($self->{option_results}->{use_regexp}) && $result->{vsvrName} =~ /$self->{option_results}->{name}/) { health => $options{result}->{vsvrHealth},
$self->add_result(instance => $instance, result => $result); state => $options{result}->{vsvrState},
} };
} }
if (scalar(keys %{$self->{vservers}}) <= 0) { if (scalar(keys %{$self->{vservers}}) <= 0) {
@ -241,13 +231,9 @@ Threshold warning in percent.
Threshold critical in percent. Threshold critical in percent.
=item B<--name> =item B<--filter-name>
Set the virtual server name. Filter by virtual server name (can be a regexp).
=item B<--regexp>
Allows to use regexp to filter virtual server name (with option --name).
=item B<--filter-type> =item B<--filter-type>