From ce419f66b7ecb2aa03e414996416c8fd2b3b85fe Mon Sep 17 00:00:00 2001 From: CPbN Date: Thu, 6 Jun 2019 00:19:08 +0200 Subject: [PATCH 1/2] Mikrotik, improve error label --- .../network/mikrotik/snmp/mode/interfaces.pm | 2 +- centreon-plugins/snmp_standard/mode/interfaces.pm | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm b/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm index d81f5a2f6..128e2ac02 100644 --- a/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/mikrotik/snmp/mode/interfaces.pm @@ -71,7 +71,7 @@ sub set_counters_errors { push @{$self->{maps_counters}->{int}}, { label => lc($1) . '-' . lc($2), filter => 'add_errors', nlabel => 'interface.packets.' . lc($1) . '.' . lc($2) . '.count', set => { key_values => [ { name => lc($1.$2), diff => 1 }, { name => 'total_' . lc($1) . '_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], - closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => lc($1), label_ref2 => lc($2) }, + closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label => $1 . ' ' . $2, label_ref1 => lc($1), label_ref2 => lc($2) }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets ' . $1 . ' ' . $2 . ' : %s', closure_custom_perfdata => $self->can('custom_errors_perfdata'), closure_custom_threshold_check => $self->can('custom_errors_threshold'), diff --git a/centreon-plugins/snmp_standard/mode/interfaces.pm b/centreon-plugins/snmp_standard/mode/interfaces.pm index 18c22e71a..42d65e043 100644 --- a/centreon-plugins/snmp_standard/mode/interfaces.pm +++ b/centreon-plugins/snmp_standard/mode/interfaces.pm @@ -236,8 +236,8 @@ sub custom_errors_threshold { sub custom_errors_output { my ($self, %options) = @_; - my $msg = sprintf("Packets %s %s : %.2f%% (%s)", - ucfirst($self->{result_values}->{label1}), ucfirst($self->{result_values}->{label2}), + my $msg = sprintf("Packets %s : %.2f%% (%s)", + $self->{result_values}->{label}, $self->{result_values}->{prct}, $self->{result_values}->{used}); return $msg; } @@ -263,6 +263,12 @@ sub custom_errors_calc { $self->{result_values}->{prct} = $total == 0 ? 0 : $diff * 100 / $total; $self->{result_values}->{used} = $diff; $self->{result_values}->{total} = $total; + $self->{result_values}->{label} = $options{extra_options}->{label}; + if (defined($options{extra_options}->{label})) { + $self->{result_values}->{label} = $options{extra_options}->{label}; + } else { + $self->{result_values}->{label} = ucfirst($options{extra_options}->{label_ref1}) . ' ' . ucfirst($options{extra_options}->{label_ref2}); + } $self->{result_values}->{label1} = $options{extra_options}->{label_ref1}; $self->{result_values}->{label2} = $options{extra_options}->{label_ref2}; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; From 81738af1f24297e98f62ad92ca907b0b75d610a8 Mon Sep 17 00:00:00 2001 From: CPbN Date: Thu, 6 Jun 2019 00:21:46 +0200 Subject: [PATCH 2/2] Typo --- centreon-plugins/snmp_standard/mode/interfaces.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/centreon-plugins/snmp_standard/mode/interfaces.pm b/centreon-plugins/snmp_standard/mode/interfaces.pm index 42d65e043..d9301749e 100644 --- a/centreon-plugins/snmp_standard/mode/interfaces.pm +++ b/centreon-plugins/snmp_standard/mode/interfaces.pm @@ -263,7 +263,6 @@ sub custom_errors_calc { $self->{result_values}->{prct} = $total == 0 ? 0 : $diff * 100 / $total; $self->{result_values}->{used} = $diff; $self->{result_values}->{total} = $total; - $self->{result_values}->{label} = $options{extra_options}->{label}; if (defined($options{extra_options}->{label})) { $self->{result_values}->{label} = $options{extra_options}->{label}; } else {