Mikrotik, improve error label
This commit is contained in:
parent
38e5ebdfd7
commit
41df0a45bf
|
@ -71,7 +71,7 @@ sub set_counters_errors {
|
||||||
push @{$self->{maps_counters}->{int}},
|
push @{$self->{maps_counters}->{int}},
|
||||||
{ label => lc($1) . '-' . lc($2), filter => 'add_errors', nlabel => 'interface.packets.' . lc($1) . '.' . lc($2) . '.count', set => {
|
{ 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' } ],
|
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_output => $self->can('custom_errors_output'), output_error_template => 'Packets ' . $1 . ' ' . $2 . ' : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
|
|
|
@ -236,8 +236,8 @@ sub custom_errors_threshold {
|
||||||
sub custom_errors_output {
|
sub custom_errors_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf("Packets %s %s : %.2f%% (%s)",
|
my $msg = sprintf("Packets %s : %.2f%% (%s)",
|
||||||
ucfirst($self->{result_values}->{label1}), ucfirst($self->{result_values}->{label2}),
|
$self->{result_values}->{label},
|
||||||
$self->{result_values}->{prct}, $self->{result_values}->{used});
|
$self->{result_values}->{prct}, $self->{result_values}->{used});
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,12 @@ sub custom_errors_calc {
|
||||||
$self->{result_values}->{prct} = $total == 0 ? 0 : $diff * 100 / $total;
|
$self->{result_values}->{prct} = $total == 0 ? 0 : $diff * 100 / $total;
|
||||||
$self->{result_values}->{used} = $diff;
|
$self->{result_values}->{used} = $diff;
|
||||||
$self->{result_values}->{total} = $total;
|
$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}->{label1} = $options{extra_options}->{label_ref1};
|
||||||
$self->{result_values}->{label2} = $options{extra_options}->{label_ref2};
|
$self->{result_values}->{label2} = $options{extra_options}->{label_ref2};
|
||||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||||
|
|
Loading…
Reference in New Issue