From 826f9dc5e6a8e599e7a51b0e6f1c9e2abfc91e58 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Tue, 29 Aug 2017 13:31:46 +0200 Subject: [PATCH] add option in numeric-value --- centreon-plugins/snmp_standard/mode/numericvalue.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/snmp_standard/mode/numericvalue.pm b/centreon-plugins/snmp_standard/mode/numericvalue.pm index e75352489..6cf4770ca 100644 --- a/centreon-plugins/snmp_standard/mode/numericvalue.pm +++ b/centreon-plugins/snmp_standard/mode/numericvalue.pm @@ -41,6 +41,7 @@ sub new { "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "format:s" => { name => 'format' }, + "format-custom:s" => { name => 'format_custom' }, "format-scale" => { name => 'format_scale' }, "format-scale-type:s" => { name => 'format_scale_type' }, "perfdata-unit:s" => { name => 'perfdata_unit' }, @@ -83,7 +84,8 @@ sub add_data { $self->{output}->option_exit(); } - foreach (['oid_type', 'gauge'], ['counter_per_seconds'], ['format', 'current value is %s'], ['format_scale'], + foreach (['oid_type', 'gauge'], ['counter_per_seconds'], ['format', 'current value is %s'], + ['format_custom', ''], ['format_scale'], ['perfdata_unit', ''], ['perfdata_name', 'value'], ['perfdata_min', ''], ['perfdata_max', '']) { if (defined($options{data}->{$_->[0]})) { @@ -172,6 +174,10 @@ sub check_data { } } + if ($options{entry}->{format_custom} ne '') { + $value = eval "$value $options{entry}->{format_custom}"; + } + my $exit = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical-' . $options{num}, exit_litteral => 'critical' }, { label => 'warning-' . $options{num}, exit_litteral => 'warning' } ]); if (defined($options{entry}->{format_scale})) { @@ -255,6 +261,11 @@ Convert counter value on a value per seconds (only with type 'counter'). Output format (Default: 'current value is %s') +=item B<--format-custom> + +Apply a custom change on the value +(Example to multiply the value: --format-custom='* 8'). + =item B<--format-scale> Scale bytes value. We'll display value in output.