(plugin) apps::monitoring:kadiska - removing old perfdata labels (#3638)

* initial discovery for watchers

* divide discovery for station and watcher

* initial commit

* add period option and set help

* remove unused dependancy

* fix couters nlabel and period calculation method

* modify default value for period

* remove old perfdata labels and unused if condition

* format
This commit is contained in:
lchrdn 2022-05-04 23:23:17 +02:00 committed by GitHub
parent eb5c702e01
commit 3f13066ccd
2 changed files with 17 additions and 18 deletions

View File

@ -44,7 +44,7 @@ sub set_counters {
key_values => [ { name => 'round_trip' }], key_values => [ { name => 'round_trip' }],
output_template => 'Round trip: %.2f ms', output_template => 'Round trip: %.2f ms',
perfdatas => [ perfdatas => [
{ label => 'round_trip', template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1 }, { template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1 },
], ],
} }
}, },
@ -52,7 +52,7 @@ sub set_counters {
key_values => [ { name => 'path_length' } ], key_values => [ { name => 'path_length' } ],
output_template => 'Path length: %.2f', output_template => 'Path length: %.2f',
perfdatas => [ perfdatas => [
{ label => 'path_length', template => '%.2f', min => 0, label_extra_instance => 1 }, { template => '%.2f', min => 0, label_extra_instance => 1 },
], ],
} }
}, },
@ -60,7 +60,7 @@ sub set_counters {
key_values => [ { name => 'packets_loss_prct' } ], key_values => [ { name => 'packets_loss_prct' } ],
output_template => 'Packets Loss: %.2f %%', output_template => 'Packets Loss: %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'packets_loss_prct', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, { template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 },
], ],
} }
} }
@ -132,10 +132,10 @@ sub manage_selection {
my $instance = $watcher->{"tracer:group"}; my $instance = $watcher->{"tracer:group"};
$self->{targets}->{$instance} = { $self->{targets}->{$instance} = {
round_trip => ($watcher->{'rtt_furthest:avg'} / 1000), round_trip => ($watcher->{'rtt_furthest:avg'} / 1000),
packets_loss_prct => $watcher->{'loss_furthest:avg'}, packets_loss_prct => $watcher->{'loss_furthest:avg'},
path_length => $watcher->{'length_furthest:avg'}, path_length => $watcher->{'length_furthest:avg'},
} };
}; };
if (scalar(keys %{$self->{targets}}) <= 0) { if (scalar(keys %{$self->{targets}}) <= 0) {

View File

@ -44,7 +44,7 @@ sub set_counters {
key_values => [ { name => 'errors_prct' } ], key_values => [ { name => 'errors_prct' } ],
output_template => 'errors: %.2f%%', output_template => 'errors: %.2f%%',
perfdatas => [ perfdatas => [
{ label => 'errors_prct', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, { template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 },
], ],
} }
}, },
@ -52,7 +52,7 @@ sub set_counters {
key_values => [ { name => 'sessions' } ], key_values => [ { name => 'sessions' } ],
output_template => 'sessions: %s', output_template => 'sessions: %s',
perfdatas => [ perfdatas => [
{ label => 'sessions', template => '%s', min => 0, label_extra_instance => 1 }, { template => '%s', min => 0, label_extra_instance => 1 },
], ],
} }
}, },
@ -60,7 +60,7 @@ sub set_counters {
key_values => [ { name => 'requests' } ], key_values => [ { name => 'requests' } ],
output_template => 'requests: %s', output_template => 'requests: %s',
perfdatas => [ perfdatas => [
{ label => 'requests', template => '%s', min => 0, label_extra_instance => 1 }, { template => '%s', min => 0, label_extra_instance => 1 },
], ],
} }
}, },
@ -68,7 +68,7 @@ sub set_counters {
key_values => [ { name => 'pages' } ], key_values => [ { name => 'pages' } ],
output_template => 'pages: %d', output_template => 'pages: %d',
perfdatas => [ perfdatas => [
{ label => 'pages', template => '%d', min => 0, label_extra_instance => 1 }, { template => '%d', min => 0, label_extra_instance => 1 },
], ],
} }
} }
@ -136,16 +136,15 @@ sub manage_selection {
$self->{watchers} = {}; $self->{watchers} = {};
foreach my $watcher (@{$results->{data}}) { foreach my $watcher (@{$results->{data}}) {
next if (defined($self->{option_results}->{filter_watcher_name}) && $self->{option_results}->{filter_watcher_name} ne ''
&& $watcher->{'watcher_id:group'} !~ /$self->{option_results}->{filter_watcher_name}/);
my $instance = $watcher->{'watcher_id:group'}; my $instance = $watcher->{'watcher_id:group'};
$self->{watchers}->{$instance} = { display => $instance, $self->{watchers}->{$instance} = {
errors_prct => $watcher->{'%errors:avg|hits'}, errors_prct => $watcher->{'%errors:avg|hits'},
sessions => $watcher->{'session:sum|hits'}, sessions => $watcher->{'session:sum|hits'},
requests => $watcher->{'item:count|requests'}, requests => $watcher->{'item:count|requests'},
pages => $watcher->{'item:count|pages'} }; pages => $watcher->{'item:count|pages'}
};
}; };
if (scalar(keys %{$self->{watchers}}) <= 0) { if (scalar(keys %{$self->{watchers}}) <= 0) {