(plugin) storage::netapp:ontap::restapi - fix missing counters for space usage and bug in listvolumes (#4041)
* fix missing filter option and missing counters * fix 'uninitialized value in sprintf' in listvol
This commit is contained in:
parent
d2d51f99d2
commit
9b0495633e
|
@ -73,6 +73,33 @@ sub set_counters {
|
|||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'usage', nlabel => 'aggregate.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ value => 'used_space', template => '%d', min => 0, max => 'total_space',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-free', nlabel => 'aggregate.space.free.bytes', display_ok => 0, set => {
|
||||
key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ value => 'free_space', template => '%d', min => 0, max => 'total_space',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-prct', nlabel => 'aggregate.space.usage.percentage', display_ok => 0, set => {
|
||||
key_values => [ { name => 'prct_used_space' }, { name => 'display' } ],
|
||||
output_template => 'used : %.2f %%',
|
||||
perfdatas => [
|
||||
{ value => 'prct_used_space', template => '%.2f', min => 0, max => 100,
|
||||
unit => '%', label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'read', nlabel => 'aggregate.io.read.usage.bytespersecond', display_ok => 0, set => {
|
||||
key_values => [ { name => 'read' } ],
|
||||
output_template => 'read: %s %s/s',
|
||||
|
@ -183,6 +210,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -195,6 +223,8 @@ sub manage_selection {
|
|||
|
||||
$self->{aggregates} = {};
|
||||
foreach (@{$aggregates->{records}}) {
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$_->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||
my $name = $_->{name};
|
||||
my $uuid = $_->{uuid};
|
||||
|
||||
|
@ -206,6 +236,10 @@ sub manage_selection {
|
|||
total_space => $_->{space}->{block_storage}->{size},
|
||||
used_space => $_->{space}->{block_storage}->{used},
|
||||
free_space => $_->{space}->{block_storage}->{available},
|
||||
prct_used_space =>
|
||||
($_->{space}->{block_storage}->{used} * 100 / $_->{space}->{block_storage}->{size}),
|
||||
prct_free_space =>
|
||||
($_->{space}->{block_storage}->{available} * 100 / $_->{space}->{block_storage}->{size}),
|
||||
read => $agg->{metric}->{throughput}->{read},
|
||||
write => $agg->{metric}->{throughput}->{write},
|
||||
other => $agg->{metric}->{throughput}->{other},
|
||||
|
|
|
@ -53,10 +53,11 @@ sub run {
|
|||
my $volumes = $self->manage_selection(%options);
|
||||
foreach (@{$volumes->{records}}) {
|
||||
my $vserver_name = defined($_->{svm}) && $_->{svm}->{name} ne '' ? $_->{svm}->{name} : '-';
|
||||
my $volume_state = defined($_->{state}) && $_->{state} ne '' ? $_->{state} : '-';
|
||||
$self->{output}->output_add(long_msg => sprintf(
|
||||
'[name = %s][state = %s][vserver = %s]',
|
||||
$_->{name},
|
||||
$_->{state},
|
||||
$volume_state,
|
||||
$vserver_name
|
||||
));
|
||||
}
|
||||
|
@ -81,10 +82,11 @@ sub disco_show {
|
|||
my $volumes = $self->manage_selection(%options);
|
||||
foreach (@{$volumes->{records}}) {
|
||||
my $vserver_name = defined($_->{svm}) && $_->{svm}->{name} ne '' ? $_->{svm}->{name} : '-';
|
||||
my $volume_state = defined($_->{state}) && $_->{state} ne '' ? $_->{state} : '-';
|
||||
$self->{output}->add_disco_entry(
|
||||
name => $_->{name},
|
||||
state => $_->{state},
|
||||
vserver_name => $_->{svm}->{name}
|
||||
state => $volume_state,
|
||||
vserver_name => $vserver_name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue