Fix #1908
This commit is contained in:
parent
530888addf
commit
6d63e0c8ce
|
@ -33,11 +33,12 @@ sub custom_usage_output {
|
||||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute});
|
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute});
|
||||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute});
|
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute});
|
||||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute});
|
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute});
|
||||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
return sprintf(
|
||||||
|
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
|
||||||
$total_size_value . " " . $total_size_unit,
|
$total_size_value . " " . $total_size_unit,
|
||||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute},
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute},
|
||||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute});
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute}
|
||||||
return $msg;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
|
@ -53,10 +54,10 @@ sub set_counters {
|
||||||
key_values => [ { name => 'count' } ],
|
key_values => [ { name => 'count' } ],
|
||||||
output_template => 'Partitions count : %d',
|
output_template => 'Partitions count : %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'count', value => 'count_absolute', template => '%d', min => 0 },
|
{ label => 'count', value => 'count_absolute', template => '%d', min => 0 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{diskpath} = [
|
$self->{maps_counters}->{diskpath} = [
|
||||||
|
@ -65,8 +66,8 @@ sub set_counters {
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
|
{ label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
|
||||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage-free', display_ok => 0, nlabel => 'storage.space.free.bytes', set => {
|
{ label => 'usage-free', display_ok => 0, nlabel => 'storage.space.free.bytes', set => {
|
||||||
|
@ -74,8 +75,8 @@ sub set_counters {
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute',
|
{ label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute',
|
||||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'storage.space.usage.percentage', set => {
|
{ label => 'usage-prct', display_ok => 0, nlabel => 'storage.space.usage.percentage', set => {
|
||||||
|
@ -83,8 +84,8 @@ sub set_counters {
|
||||||
output_template => 'Used : %.2f %%',
|
output_template => 'Used : %.2f %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100,
|
{ label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100,
|
||||||
unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'inodes', nlabel => 'storage.inodes.usage.percentage', set => {
|
{ label => 'inodes', nlabel => 'storage.inodes.usage.percentage', set => {
|
||||||
|
@ -92,10 +93,10 @@ sub set_counters {
|
||||||
output_template => 'Inodes Used: %s %%',
|
output_template => 'Inodes Used: %s %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'inodes', value => 'inodes_absolute', template => '%d',
|
{ label => 'inodes', value => 'inodes_absolute', template => '%d',
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,16 +180,18 @@ sub manage_selection {
|
||||||
my $name_diskpath = $self->get_display_value(id => $_);
|
my $name_diskpath = $self->get_display_value(id => $_);
|
||||||
|
|
||||||
if (!defined($result->{$oid_dskTotalHigh . "." . $_})) {
|
if (!defined($result->{$oid_dskTotalHigh . "." . $_})) {
|
||||||
$self->{output}->add_option_msg(long_msg => sprintf(
|
$self->{output}->add_option_msg(
|
||||||
|
long_msg => sprintf(
|
||||||
"skipping partition '%s': not found (need to reload the cache)",
|
"skipping partition '%s': not found (need to reload the cache)",
|
||||||
$name_diskpath)
|
$name_diskpath
|
||||||
|
)
|
||||||
);
|
);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $total_size = (($result->{$oid_dskTotalHigh . "." . $_} << 32) + $result->{$oid_dskTotalLow . "." . $_}) * 1024;
|
my $total_size = (($result->{$oid_dskTotalHigh . "." . $_} << 32) + $result->{$oid_dskTotalLow . "." . $_}) * 1024;
|
||||||
if ($total_size == 0) {
|
if ($total_size == 0) {
|
||||||
$self->{output}->output_add(long_msg => sprintf("skipping partition '%s' (total size is 0)", $name_diskpath));
|
$self->{output}->output_add(long_msg => sprintf("skipping partition '%s' (total size is 0)", $name_diskpath), debug => 1);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
my $total_used = (($result->{$oid_dskUsedHigh . "." . $_} << 32) + $result->{$oid_dskUsedLow . "." . $_}) * 1024;
|
my $total_used = (($result->{$oid_dskUsedHigh . "." . $_} << 32) + $result->{$oid_dskUsedLow . "." . $_}) * 1024;
|
||||||
|
@ -221,7 +224,7 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{diskpath}}) <= 0) {
|
if (scalar(keys %{$self->{diskpath}}) <= 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Issue with disk path information (see details)");
|
$self->{output}->add_option_msg(short_msg => 'Issue with disk path information (see details)');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,11 +273,11 @@ sub get_selection {
|
||||||
my $all_ids = $self->{statefile_cache}->get(name => 'all_ids');
|
my $all_ids = $self->{statefile_cache}->get(name => 'all_ids');
|
||||||
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{diskpath})) {
|
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{diskpath})) {
|
||||||
# get by ID
|
# get by ID
|
||||||
my $name = $self->{statefile_cache}->get(name => "dskPath_" . $self->{option_results}->{diskpath});
|
my $name = $self->{statefile_cache}->get(name => 'dskPath_' . $self->{option_results}->{diskpath});
|
||||||
push @{$self->{diskpath_id_selected}}, $self->{option_results}->{diskpath} if (defined($name));
|
push @{$self->{diskpath_id_selected}}, $self->{option_results}->{diskpath} if (defined($name));
|
||||||
} else {
|
} else {
|
||||||
foreach my $i (@{$all_ids}) {
|
foreach my $i (@{$all_ids}) {
|
||||||
my $filter_name = $self->{statefile_cache}->get(name => "dskPath_" . $i);
|
my $filter_name = $self->{statefile_cache}->get(name => 'dskPath_' . $i);
|
||||||
next if (!defined($filter_name));
|
next if (!defined($filter_name));
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{diskpath})) {
|
if (!defined($self->{option_results}->{diskpath})) {
|
||||||
|
@ -301,12 +304,13 @@ sub get_selection {
|
||||||
|
|
||||||
sub get_display_value {
|
sub get_display_value {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
my $value = $self->{statefile_cache}->get(name => "dskPath_" . $options{id});
|
my $value = $self->{statefile_cache}->get(name => 'dskPath_' . $options{id});
|
||||||
|
|
||||||
if (defined($self->{option_results}->{display_transform_src})) {
|
if (defined($self->{option_results}->{display_transform_src})) {
|
||||||
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
|
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
|
||||||
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
|
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,13 @@ sub custom_usage_threshold {
|
||||||
$threshold_value = $self->{result_values}->{prct_used};
|
$threshold_value = $self->{result_values}->{prct_used};
|
||||||
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
|
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
|
||||||
}
|
}
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(
|
||||||
|
value => $threshold_value,
|
||||||
|
threshold => [
|
||||||
|
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' }
|
||||||
|
]
|
||||||
|
);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +122,12 @@ sub custom_usage_output {
|
||||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
return sprintf(
|
||||||
|
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
|
||||||
$total_size_value . " " . $total_size_unit,
|
$total_size_value . " " . $total_size_unit,
|
||||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||||
return $msg;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_calc {
|
sub custom_usage_calc {
|
||||||
|
@ -171,8 +178,8 @@ sub set_counters {
|
||||||
key_values => [ { name => 'count' } ],
|
key_values => [ { name => 'count' } ],
|
||||||
output_template => 'Partitions count : %d',
|
output_template => 'Partitions count : %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'count', value => 'count_absolute', template => '%d', min => 0 },
|
{ label => 'count', value => 'count_absolute', template => '%d', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -183,7 +190,7 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'access', nlabel => 'storage.access', set => {
|
{ label => 'access', nlabel => 'storage.access', set => {
|
||||||
|
@ -191,10 +198,10 @@ sub set_counters {
|
||||||
closure_custom_output => $self->can('custom_access_output'),
|
closure_custom_output => $self->can('custom_access_output'),
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'access', value => 'access_absolute', template => '%d', min => 1, max => 2,
|
{ label => 'access', value => 'access_absolute', template => '%d', min => 1, max => 2,
|
||||||
label_extra_instance => 1, instance_use => 'display_absolute' },
|
label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +337,13 @@ sub manage_selection {
|
||||||
# in bytes hrStorageAllocationUnits
|
# in bytes hrStorageAllocationUnits
|
||||||
my $total_size = $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_};
|
my $total_size = $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_};
|
||||||
if ($total_size <= 0) {
|
if ($total_size <= 0) {
|
||||||
$self->{output}->add_option_msg(
|
$self->{output}->output_add(
|
||||||
long_msg => sprintf(
|
long_msg => sprintf(
|
||||||
"skipping storage '%s': total size is <= 0 (%s)",
|
"skipping storage '%s': total size is <= 0 (%s)",
|
||||||
$name_storage,
|
$name_storage,
|
||||||
int($total_size)
|
int($total_size)
|
||||||
)
|
),
|
||||||
|
debug => 1
|
||||||
);
|
);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue