From 09407c878d1849bba2dc8a53fe860f1ca342d062 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Mon, 12 Jul 2021 16:13:10 +0200 Subject: [PATCH] fix(linux/local): storage mode calc (#2957) --- centreon-plugins/os/linux/local/mode/storage.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/centreon-plugins/os/linux/local/mode/storage.pm b/centreon-plugins/os/linux/local/mode/storage.pm index 41e70d30b..26d6604a9 100644 --- a/centreon-plugins/os/linux/local/mode/storage.pm +++ b/centreon-plugins/os/linux/local/mode/storage.pm @@ -89,8 +89,8 @@ sub custom_usage_calc { $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; - $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; - $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / ($self->{result_values}->{used} + $self->{result_values}->{free}); $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; return 0; @@ -105,7 +105,7 @@ sub set_counters { $self->{maps_counters}->{disks} = [ { label => 'usage', set => { - key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ], + key_values => [ { name => 'display' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), closure_custom_perfdata => $self->can('custom_usage_perfdata'), @@ -159,8 +159,14 @@ sub manage_selection { next if (defined($self->{option_results}->{filter_mountpoint}) && $self->{option_results}->{filter_mountpoint} ne '' && $mount !~ /$self->{option_results}->{filter_mountpoint}/); - $size *= 1024; - $self->{disks}->{$mount} = { display => $mount, fs => $fs, type => $type, total => $size, used => $used * 1024 }; + $self->{disks}->{$mount} = { + display => $mount, + fs => $fs, + type => $type, + total => $size * 1024, + used => $used * 1024, + free => $available * 1024 + }; } if (scalar(keys %{$self->{disks}}) <= 0) {