From 568bcf1a459e7791ea7a8416038ee927fc468069 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Tue, 7 Mar 2023 15:02:11 +0000 Subject: [PATCH] (plugin) storage::nimble::restapi - mode volumes use full_name and add --filter-replication-role option (#4260) --- src/storage/nimble/restapi/mode/volumes.pm | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/storage/nimble/restapi/mode/volumes.pm b/src/storage/nimble/restapi/mode/volumes.pm index c75e8e762..a04efa1b4 100644 --- a/src/storage/nimble/restapi/mode/volumes.pm +++ b/src/storage/nimble/restapi/mode/volumes.pm @@ -63,11 +63,11 @@ sub set_counters { } }, { label => 'space-usage', nlabel => 'volume.space.usage.bytes', set => { - key_values => [ { name => 'used_space' }, { name => 'display' } ], + key_values => [ { name => 'used_space' } ], output_template => 'space used: %s %s', output_change_bytes => 1, perfdatas => [ - { template => '%d', min => 0, unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } + { template => '%d', min => 0, unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } }, @@ -130,7 +130,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' } + 'filter-name:s' => { name => 'filter_name' }, + 'filter-replication-role:s' => { name => 'filter_replication_role' } }); return $self; @@ -144,13 +145,19 @@ sub manage_selection { $self->{volumes} = {}; foreach (@{$results->{data}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $_->{name} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping volume '" . $_->{name} . "': no matching filter.", debug => 1); + $_->{full_name} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping volume '" . $_->{full_name} . "': no matching filter.", debug => 1); next; } + if (defined($self->{option_results}->{filter_replication_role}) && $self->{option_results}->{filter_replication_role} ne '' && + $_->{replication_role} !~ /$self->{option_results}->{filter_replication_role}/) { + $self->{output}->output_add(long_msg => "skipping volume '" . $_->{full_name} . "': no matching filter.", debug => 1); + next; + } + - $self->{volumes}->{ $_->{name} } = { - display => $_->{name}, + $self->{volumes}->{ $_->{full_name} } = { + display => $_->{full_name}, state => $_->{vol_state}, space_usage_level => $_->{space_usage_level}, used_space => $_->{total_usage_bytes}, @@ -188,6 +195,10 @@ Example: --filter-counters='status' Filter volume name (can be a regexp). +=item B<--filter-replication-role> + +Filter volumes by replication role (can be a regexp). + =item B<--unknown-status> Set unknown threshold for status.