enhance vserver for netapp volumes
This commit is contained in:
parent
50db0dcea1
commit
69b2e5e0c1
|
@ -52,10 +52,12 @@ sub run {
|
||||||
|
|
||||||
my $volumes = $self->manage_selection(%options);
|
my $volumes = $self->manage_selection(%options);
|
||||||
foreach (@{$volumes->{records}}) {
|
foreach (@{$volumes->{records}}) {
|
||||||
|
my $vserver_name = defined($_->{svm}) && $_->{svm}->{name} ne '' ? $_->{svm}->{name} : '-';
|
||||||
$self->{output}->output_add(long_msg => sprintf(
|
$self->{output}->output_add(long_msg => sprintf(
|
||||||
'[name = %s][state = %s]',
|
'[name = %s][state = %s][vserver = %s]',
|
||||||
$_->{name},
|
$_->{name},
|
||||||
$_->{state}
|
$_->{state},
|
||||||
|
$vserver_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ sub run {
|
||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name', 'state']);
|
$self->{output}->add_disco_format(elements => ['name', 'state', 'vserver_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
|
@ -78,9 +80,11 @@ sub disco_show {
|
||||||
|
|
||||||
my $volumes = $self->manage_selection(%options);
|
my $volumes = $self->manage_selection(%options);
|
||||||
foreach (@{$volumes->{records}}) {
|
foreach (@{$volumes->{records}}) {
|
||||||
|
my $vserver_name = defined($_->{svm}) && $_->{svm}->{name} ne '' ? $_->{svm}->{name} : '-';
|
||||||
$self->{output}->add_disco_entry(
|
$self->{output}->add_disco_entry(
|
||||||
name => $_->{name},
|
name => $_->{name},
|
||||||
state => $_->{state}
|
state => $_->{state},
|
||||||
|
vserver_name => $_->{svm}->{name}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,8 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-name:s' => { name => 'filter_name' }
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'filter-vserver-name:s' => { name => 'filter_vserver_name' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -166,14 +167,22 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{volumes} = {};
|
$self->{volumes} = {};
|
||||||
foreach (@{$volumes->{records}}) {
|
foreach (@{$volumes->{records}}) {
|
||||||
|
my $name = defined($_->{svm}) && $_->{svm}->{name} ne '' ?
|
||||||
|
$_->{svm}->{name} . ':' . $_->{name} :
|
||||||
|
$_->{name};
|
||||||
|
if (defined($self->{option_results}->{filter_vserver_name}) && $self->{option_results}->{filter_vserver_name} ne '' &&
|
||||||
|
defined($_->{svm}) && $_->{svm}->{name} ne '' && $_->{svm}->{name} !~ /$self->{option_results}->{filter_vserver_name}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $_->{svm}->{name} . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
$_->{name} !~ /$self->{option_results}->{filter_name}/) {
|
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping volume '" . $_->{name} . "': no matching filter.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping volume '" . $name . "': no matching filter.", debug => 1);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{volumes}->{ $_->{name} } = {
|
$self->{volumes}->{$name} = {
|
||||||
display => $_->{name},
|
display => $name,
|
||||||
state => $_->{state},
|
state => $_->{state},
|
||||||
|
|
||||||
total_space => $_->{space}->{size},
|
total_space => $_->{space}->{size},
|
||||||
|
@ -216,6 +225,10 @@ Example: --filter-counters='^usage$'
|
||||||
|
|
||||||
Filter volume name (can be a regexp).
|
Filter volume name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--filter-vserver-name>
|
||||||
|
|
||||||
|
Filter volumes by vserver name (can be a regexp).
|
||||||
|
|
||||||
=item B<--unknown-status>
|
=item B<--unknown-status>
|
||||||
|
|
||||||
Set unknown threshold for status.
|
Set unknown threshold for status.
|
||||||
|
|
Loading…
Reference in New Issue