From f5b6dd18fcc4f5b11c1be11f49ec32fac67b1a0e Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Mon, 29 Jun 2020 22:30:42 +0200 Subject: [PATCH] enh(storage) Add --filter-duplicate option --- snmp_standard/mode/storage.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/snmp_standard/mode/storage.pm b/snmp_standard/mode/storage.pm index 9f877ff1c..b217c4438 100644 --- a/snmp_standard/mode/storage.pm +++ b/snmp_standard/mode/storage.pm @@ -236,6 +236,7 @@ sub new { 'display-transform-dst:s' => { name => 'display_transform_dst' }, 'show-cache' => { name => 'show_cache' }, 'space-reservation:s' => { name => 'space_reservation' }, + 'filter-duplicate' => { name => 'filter_duplicate' }, 'filter-storage-type:s' => { name => 'filter_storage_type', default => $self->default_storage_type() }, 'add-access' => { name => 'add_access' }, }); @@ -348,6 +349,18 @@ sub manage_selection { next; } + if (defined($self->{option_results}->{filter_duplicate})) { + my $sid = $_; + my @duplicate = grep { + ($self->{storage}->{$_}->{allocation_units} == $result->{$oid_hrStorageAllocationUnits . "." . $sid}) && + ($self->{storage}->{$_}->{size} == $result->{$oid_hrStorageSize . "." . $sid}) && + ($self->{storage}->{$_}->{used} == $result->{$oid_hrStorageUsed . "." . $sid}) + } keys $self->{storage}; + if (scalar(@duplicate)) { + next; + } + } + $self->{storage}->{$_} = { display => $name_storage, allocation_units => $result->{$oid_hrStorageAllocationUnits . "." . $_}, @@ -581,6 +594,10 @@ Display cache storage datas. Some filesystem has space reserved (like ext4 for root). The value is in percent of total (Default: none) (results like 'df' command). +=item B<--filter-duplicate> + +Filter duplicate storages (in used size and total size). + =item B<--filter-storage-type> Filter storage types with a regexp (Default: '^(hrStorageFixedDisk|hrStorageNetworkDisk|hrFSBerkeleyFFS)$').