diff --git a/network/mikrotik/snmp/mode/interfaces.pm b/network/mikrotik/snmp/mode/interfaces.pm index d81f5a2f6..128e2ac02 100644 --- a/network/mikrotik/snmp/mode/interfaces.pm +++ b/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/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index 18c22e71a..42d65e043 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/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'};