mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
enh(mode): snmp numeric value output (#2680)
This commit is contained in:
parent
fcb10404ce
commit
09eda85b2e
@ -33,21 +33,21 @@ sub new {
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'oid:s' => { name => 'oid' },
|
||||
'oid-type:s' => { name => 'oid_type' },
|
||||
'counter-per-seconds' => { name => 'counter_per_seconds' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'extracted-pattern:s' => { name => 'extracted_pattern' },
|
||||
'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' },
|
||||
'perfdata-name:s' => { name => 'perfdata_name' },
|
||||
'perfdata-min:s' => { name => 'perfdata_min' },
|
||||
'perfdata-max:s' => { name => 'perfdata_max' },
|
||||
'config-json:s' => { name => 'config_json' },
|
||||
'oid:s' => { name => 'oid' },
|
||||
'oid-type:s' => { name => 'oid_type' },
|
||||
'counter-per-seconds' => { name => 'counter_per_seconds' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'extracted-pattern:s' => { name => 'extracted_pattern' },
|
||||
'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' },
|
||||
'perfdata-name:s' => { name => 'perfdata_name' },
|
||||
'perfdata-min:s' => { name => 'perfdata_min' },
|
||||
'perfdata-max:s' => { name => 'perfdata_max' },
|
||||
'config-json:s' => { name => 'config_json' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
@ -199,10 +199,9 @@ sub check_data {
|
||||
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})) {
|
||||
my ($value_mod, $value_unit) = $self->{perfdata}->change_bytes(value => $value);
|
||||
if ($options{entry}->{format_scale_type} =~ /^network$/i) {
|
||||
($value_mod, $value_unit) = $self->{perfdata}->change_bytes(value => $value, network => 1);
|
||||
}
|
||||
my $network = $options{entry}->{format_scale_type} =~ /^network$/i ? { network => 1 } : {};
|
||||
my ($value_mod, $value_unit) = $self->{perfdata}->change_bytes(value => $value, %{$network});
|
||||
$value_unit .= '/s' if (defined($options{entry}->{counter_per_seconds}));
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($options{entry}->{format}, $value_mod . $value_unit));
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user