(plugin) apps::monitoring::kadiska - change stations to runners ()

This commit is contained in:
qgarnier 2022-12-14 13:42:30 +00:00 committed by GitHub
parent d96186aca0
commit cf39e53313
7 changed files with 220 additions and 242 deletions

View File

@ -185,28 +185,26 @@ sub forge_select {
$filters{gateway_name} = $options{gateway_name} if defined($options{gateway_name}) && $options{gateway_name} ne '';
$filters{site_name} = $options{site_name} if defined($options{site_name}) && $options{site_name} ne '';
$filters{watcher_name} = $options{watcher_name} if defined($options{watcher_name}) && $options{watcher_name} ne '';
$filters{wfa} = $options{wfa} eq 'yes' ? 1 : undef ;
$filters{wfa} = 1 if ($options{wfa} eq 'yes');
my @filter;
if (keys %filters > 1){
foreach my $filter_name (keys %filters){
if ($filter_name eq 'wfa'){
unshift(@filter, ["=", "wfa", \1]) if defined($filters{$filter_name});
next;
}
unshift(@filter, ["=", $filter_name,["\$", $filters{$filter_name}]]);
my $multiple = scalar(keys %filters);
my @filter = ();
foreach my $filter_name (keys %filters) {
my @entry;
if ($filter_name eq 'wfa') {
@entry = $multiple > 1 ? (["=", "wfa", \1]) : ("=", "wfa", \1);
} else {
@entry = $multiple > 1 ? (["=", $filter_name, ['$', $filters{$filter_name}]]) : ("=", $filter_name, ['$', $filters{$filter_name}]);
}
unshift(@filter, @entry);
}
if ($multiple > 1) {
unshift(@filter, 'and');
return \@filter;
} elsif ( keys %filters == 1) {
my ($filter_name) = %filters;
my $filter_value = $filters{$filter_name};
unshift(@filter, "=", $filter_name ,["\$", $filter_value ]);
return \@filter;
}
return undef;
return \@filter;
}
sub request_api {
@ -318,4 +316,4 @@ Set timeout in seconds (Default: 10).
=back
=cut
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package apps::monitoring::kadiska::mode::liststations;
package apps::monitoring::kadiska::mode::listrunners;
use base qw(centreon::plugins::mode);
@ -53,14 +53,14 @@ sub manage_selection {
my $raw_form_post = {
"select" => [
"station_name",
"station_id"
"runner_name",
"runner_id"
],
"from" => "traceroute",
"groupby" => [
"station_id"
],
"options" => {"sampling" => \1 }
"from" => "traceroute",
"groupby" => [
"runner_id"
],
"options" => { "sampling" => \1 }
};
my $results = $options{custom}->request_api(
@ -71,8 +71,8 @@ sub manage_selection {
foreach my $current_station (@{$results->{data}}) {
my %station;
$station{station_name} = $current_station->{station_name};
$station{station_id} = $current_station->{station_id};
$station{runner_name} = $current_station->{runner_name};
$station{runner_id} = $current_station->{runner_id};
push @disco_data, \%station;
}
@ -111,10 +111,10 @@ __END__
=head1 MODE
Kadiska hosts discovery for stations.
Kadiska hosts discovery for runners.
=over 8
=back
=cut
=cut

View File

@ -31,24 +31,18 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'station-name:s' => { name => 'station_name' }
'runner-name:s' => { name => 'runner_name' }
});
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{station_name}) || $self->{option_results}->{station_name} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --station-name option.");
if (!defined($self->{option_results}->{runner_name}) || $self->{option_results}->{runner_name} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --runner-name option.");
$self->{output}->option_exit();
}
}
@ -66,28 +60,26 @@ sub manage_selection {
],
"offset" => 0,
"options" => {"sampling" => \1 }
};
};
$raw_form_post->{where} = ["=","station_name",["\$", $self->{option_results}->{station_name}]];
$raw_form_post->{where} = ["=","runner_name",["\$", $self->{option_results}->{runner_name}]];
$self->{targets} = $options{custom}->request_api(
method => 'POST',
endpoint => 'query',
query_form_post => $raw_form_post
);
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $target (@{$self->{targets}->{data}}){
$self->{output}->output_add(
long_msg => sprintf("[target = %s][station = %s]",
long_msg => sprintf("[target: %s][runner: %s]",
$target->{target_name},
$self->{option_results}->{station_name}
$self->{option_results}->{runner_name}
)
);
}
@ -103,7 +95,7 @@ sub run {
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['target', 'station']);
$self->{output}->add_disco_format(elements => ['target', 'runner']);
}
sub disco_show {
@ -113,8 +105,8 @@ sub disco_show {
foreach my $target (@{$self->{targets}->{data}}){
$self->{output}->add_disco_entry(
target => $target->{target_name},
station => $self->{option_results}->{station_name}
target => $target->{target_name},
runner => $self->{option_results}->{runner_name}
);
}
}
@ -125,14 +117,14 @@ __END__
=head1 MODE
List tracer targets for a given station.
List tracer targets for a given runner.
=over 8
=item B<--station-name>
=item B<--runner-name>
Specify station name to list linked tracer targets.
Specify runner name to list linked tracer targets.
=back
=cut
=cut

View File

@ -56,12 +56,12 @@ sub manage_selection {
{ "site:group" => "site_name" },
{ "gateway:group" => "gateway_name" }
],
"from" => "rum",
"groupby" => [
"watcher_name",
"site:group",
"gateway:group"
],
"from" => "rum",
"groupby" => [
"watcher_name",
"site:group",
"gateway:group"
],
"options" => {"sampling" => \1 }
};
@ -124,4 +124,4 @@ Kadiska hosts discovery for watchers/application.
=back
=cut
=cut

View File

@ -41,45 +41,70 @@ sub set_counters {
$self->{maps_counters}->{targets} = [
{ label => 'round-trip', nlabel => 'tracer.round.trip.persecond', set => {
key_values => [ { name => 'round_trip' }],
output_template => 'Round trip: %.2f ms',
perfdatas => [
{ template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1 },
],
key_values => [ { name => 'round_trip' }, { name => 'instance' }, { name => 'runner_name' } ],
output_template => 'round trip: %.2f ms',
closure_custom_perfdata => sub {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
nlabel => $self->{nlabel},
unit => 'ms',
instances => [$self->{result_values}->{instance}, $self->{result_values}->{runner_name}],
value => sprintf('%.2f', $self->{result_values}->{round_trip}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0
);
}
}
},
{ label => 'path-length', nlabel => 'tracer.path.length', set => {
key_values => [ { name => 'path_length' } ],
output_template => 'Path length: %.2f',
perfdatas => [
{ template => '%.2f', min => 0, label_extra_instance => 1 },
],
key_values => [ { name => 'path_length' }, { name => 'instance' }, { name => 'runner_name' } ],
output_template => 'path length: %.2f',
closure_custom_perfdata => sub {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
nlabel => $self->{nlabel},
instances => [$self->{result_values}->{instance}, $self->{result_values}->{runner_name}],
value => sprintf('%.2f', $self->{result_values}->{path_length}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0
);
}
}
},
{ label => 'packets-loss-prct', nlabel => 'tracer.packets.loss.percentage', set => {
key_values => [ { name => 'packets_loss_prct' } ],
output_template => 'Packets Loss: %.2f %%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 },
],
key_values => [ { name => 'packets_loss_prct' }, { name => 'instance' }, { name => 'runner_name' } ],
output_template => 'packets loss: %.2f %%',
closure_custom_perfdata => sub {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
nlabel => $self->{nlabel},
unit => '%',
instances => [$self->{result_values}->{instance}, $self->{result_values}->{runner_name}],
value => sprintf('%.2f', $self->{result_values}->{packets_loss_prct}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0,
max => 100
);
}
}
}
];
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-station-name:s' => { name => 'filter_station_name' },
'filter-target-name:s' => { name => 'filter_target_name' }
'filter-runner-name:s' => { name => 'filter_runner_name' },
'filter-target-name:s' => { name => 'filter_target_name' }
});
return $self;
@ -97,7 +122,7 @@ sub manage_selection {
"length_furthest:avg" => ["avg","length_furthest"]
},
{
"loss_furthest:avg" => ["*",100,["avg","loss_furthest"]]
"loss_furthest:avg" => ["*",100, ["avg","loss_furthest"] ]
},
{
"rtt_furthest:avg" => ["avg","rtt_furthest"]
@ -114,8 +139,10 @@ sub manage_selection {
"options" => {"sampling" => \1 }
};
if (defined($self->{option_results}->{filter_station_name}) && $self->{option_results}->{filter_station_name} ne ''){
$raw_form_post->{where} = ["=","station_name",["\$", $self->{option_results}->{filter_station_name}]],
my $runner_name = 'runner:all';
if (defined($self->{option_results}->{filter_runner_name}) && $self->{option_results}->{filter_runner_name} ne ''){
$raw_form_post->{where} = ["=", "runner_name", ["\$", $self->{option_results}->{filter_runner_name}]];
$runner_name = $self->{option_results}->{filter_runner_name};
}
my $results = $options{custom}->request_api(
@ -125,16 +152,18 @@ sub manage_selection {
);
$self->{targets} = {};
foreach my $station (@{$results->{data}}) {
foreach my $runner (@{$results->{data}}) {
next if (defined($self->{option_results}->{filter_target_name}) && $self->{option_results}->{filter_target_name} ne ''
&& $station->{'target:group'} !~ /^$self->{option_results}->{filter_target_name}$/);
&& $runner->{'target:group'} !~ /^$self->{option_results}->{filter_target_name}$/);
my $instance = $station->{"target:group"};
my $instance = $runner->{"target:group"};
$self->{targets}->{$instance} = {
round_trip => ($station->{'rtt_furthest:avg'} / 1000),
packets_loss_prct => $station->{'loss_furthest:avg'},
path_length => $station->{'length_furthest:avg'},
instance => $instance,
runner_name => $runner_name,
round_trip => ($runner->{'rtt_furthest:avg'} / 1000),
packets_loss_prct => $runner->{'loss_furthest:avg'},
path_length => $runner->{'length_furthest:avg'}
};
};
@ -142,7 +171,6 @@ sub manage_selection {
$self->{output}->add_option_msg(short_msg => "No instances or results found.");
$self->{output}->option_exit();
}
}
1;
@ -155,9 +183,9 @@ Check Kadiska net tracer targets' statistics during the period specified.
=over 8
=item B<--filter-station-name>
=item B<--filter-runner-name>
Filter on station name to display net tracer targets' statistics linked to a particular station.
Filter on runner name to display net tracer targets' statistics linked to a particular runner.
=item B<--filter-target-name>

View File

@ -56,20 +56,20 @@ sub custom_usage_perfdata {
sub country_prefix_output {
my ($self, %options) = @_;
return sprintf( "Country '%s' ", $options{instance});
return sprintf("Country '%s' ", $options{instance});
}
sub isp_prefix_output {
my ($self, %options) = @_;
return sprintf( "ISP '%s' ", $options{instance});
return sprintf("ISP '%s' ", $options{instance});
}
sub watcher_long_output {
my ($self, %options) = @_;
return sprintf(
"checking watcher '%s' [Site name: %s] [Gateway: %s]:",
"checking watcher '%s' [site name: %s] [gateway: %s]:",
$options{instance_value}->{watcher_name},
$options{instance_value}->{site_name},
$options{instance_value}->{gateway_name}
@ -80,7 +80,7 @@ sub prefix_watcher_output {
my ($self, %options) = @_;
return sprintf(
"Watcher '%s' [Site name: %s] [Gateway: %s] : ",
"Watcher '%s' [site name: %s] [gateway: %s] : ",
$options{instance_value}->{watcher_name},
$options{instance_value}->{site_name},
$options{instance_value}->{gateway_name}
@ -91,9 +91,9 @@ sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'country', type => 1, cb_prefix_output => 'country_prefix_output', message_multiple => 'All countries are OK'},
{ name => 'isp', type => 1, cb_prefix_output => 'isp_prefix_output', message_multiple => 'All ISP are OK'},
{ name => 'watcher', type => 3, cb_prefix_output => 'prefix_watcher_output', message_multiple => 'All watchers are OK',
{ name => 'country', type => 1, cb_prefix_output => 'country_prefix_output', message_multiple => 'All countries are ok' },
{ name => 'isp', type => 1, cb_prefix_output => 'isp_prefix_output', message_multiple => 'All ISP are ok' },
{ name => 'watcher', type => 3, cb_prefix_output => 'prefix_watcher_output', message_multiple => 'All watchers are ok',
cb_long_output => 'watcher_long_output', indent_long_output => ' ',
group => [
{ name => 'dtt_spent', type => 0, skipped_code => { -10 => 1 }},
@ -113,205 +113,205 @@ sub set_counters {
];
$self->{maps_counters}->{isp} = [
{ label => 'dtt_spent', nlabel => 'isp.dtt.spent.time.milliseconds', set => {
{ label => 'isp-dtt-spent', nlabel => 'isp.dtt.spent.time.milliseconds', set => {
key_values => [ { name => 'dtt_spent' } ],
output_template => 'DTT spent: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'errors-prct', nlabel => 'isp.errors.percentage', set => {
{ label => 'isp-errors-prct', nlabel => 'isp.errors.percentage', set => {
key_values => [ { name => 'errors_prct' } ],
output_template => 'Errors: %.2f%%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 },
],
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }
]
}
},
{ label => 'full-time-network-spent', nlabel => 'isp.network.spent.time.milliseconds', set => {
{ label => 'isp-full-time-network-spent', nlabel => 'isp.network.spent.time.milliseconds', set => {
key_values => [ { name => 'full_time_network_spent' } ],
output_template => 'Full time network spent: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'sessions', nlabel => 'isp.sessions.count', set => {
{ label => 'isp-sessions', nlabel => 'isp.sessions.count', set => {
key_values => [ { name => 'sessions' } ],
output_template => 'Sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'srt_spent', nlabel => 'isp.srt.spent.time.milliseconds', set => {
{ label => 'isp-srt-spent', nlabel => 'isp.srt.spent.time.milliseconds', set => {
key_values => [ { name => 'srt_spent' } ],
output_template => 'SRT spent: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'requests', nlabel => 'isp.requests.count', set => {
{ label => 'isp-requests', nlabel => 'isp.requests.count', set => {
key_values => [ { name => 'requests' } ],
output_template => 'Requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'redirect-time-avg', nlabel => 'isp.redirect.time.milliseconds', set => {
{ label => 'isp-redirect-time-avg', nlabel => 'isp.redirect.time.milliseconds', set => {
key_values => [ { name => 'redirect_time_avg' } ],
output_template => 'Redirect time avg: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'loading-page', nlabel => 'isp.loading.page.duration.milliseconds', set => {
{ label => 'isp-loading-page', nlabel => 'isp.loading.page.duration.milliseconds', set => {
key_values => [ { name => 'loading_page' } ],
output_template => 'Loading page duration: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'pages', nlabel => 'isp.pages.count', set => {
{ label => 'isp-pages', nlabel => 'isp.pages.count', set => {
key_values => [ { name => 'pages' } ],
output_template => 'Loaded pages: %d',
perfdatas => [
{ template => '%d', min => 0, label_extra_instance => 1 },
],
{ template => '%d', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'processing', nlabel => 'isp.processing.duration.milliseconds', set => {
{ label => 'isp-processing', nlabel => 'isp.processing.duration.milliseconds', set => {
key_values => [ { name => 'processing' } ],
output_template => 'API Processing duration: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'users', nlabel => 'users.count', set => {
{ label => 'isp-users', nlabel => 'isp.users.count', set => {
key_values => [ { name => 'users' } ],
output_template => 'Connected users: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'waiting-time-avg', nlabel => 'isp.waiting.time.milliseconds', set => {
{ label => 'isp-waiting-time-avg', nlabel => 'isp.waiting.time.milliseconds', set => {
key_values => [ { name => 'waiting_time_avg' } ],
output_template => 'Waiting time avg: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
}
];
$self->{maps_counters}->{country} = [
{ label => 'dtt_spent', nlabel => 'watcher.dtt.spent.time.milliseconds', set => {
{ label => 'country-dtt-spent', nlabel => 'watcher.dtt.spent.time.milliseconds', set => {
key_values => [ { name => 'dtt_spent' } ],
output_template => 'DTT spent: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'errors-prct', nlabel => 'watcher.errors.percentage', set => {
{ label => 'country-errors-prct', nlabel => 'watcher.errors.percentage', set => {
key_values => [ { name => 'errors_prct' } ],
output_template => 'Errors: %.2f%%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 },
],
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }
]
}
},
{ label => 'full-time-network-spent', nlabel => 'watcher.network.spent.time.milliseconds', set => {
{ label => 'country-full-time-network-spent', nlabel => 'watcher.network.spent.time.milliseconds', set => {
key_values => [ { name => 'full_time_network_spent' } ],
output_template => 'Full time network spent: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'sessions', nlabel => 'watcher.sessions.count', set => {
{ label => 'country-sessions', nlabel => 'watcher.sessions.count', set => {
key_values => [ { name => 'sessions' } ],
output_template => 'Sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'srt_spent', nlabel => 'watcher.srt.spent.time.milliseconds', set => {
{ label => 'country-srt-spent', nlabel => 'watcher.srt.spent.time.milliseconds', set => {
key_values => [ { name => 'srt_spent' } ],
output_template => 'SRT spent: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'requests', nlabel => 'watcher.requests.count', set => {
{ label => 'country-requests', nlabel => 'watcher.requests.count', set => {
key_values => [ { name => 'requests' } ],
output_template => 'Requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'redirect-time-avg', nlabel => 'watcher.redirect.time.milliseconds', set => {
{ label => 'country-redirect-time-avg', nlabel => 'watcher.redirect.time.milliseconds', set => {
key_values => [ { name => 'redirect_time_avg' } ],
output_template => 'Redirect time avg: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'loading-page', nlabel => 'watchers.loading.page.duration.milliseconds', set => {
{ label => 'country-loading-page', nlabel => 'watchers.loading.page.duration.milliseconds', set => {
key_values => [ { name => 'loading_page' } ],
output_template => 'Loading page duration: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'pages', nlabel => 'watchers.pages.count', set => {
{ label => 'country-pages', nlabel => 'watchers.pages.count', set => {
key_values => [ { name => 'pages' } ],
output_template => 'Loaded pages: %d',
perfdatas => [
{ template => '%d', min => 0, label_extra_instance => 1 },
],
{ template => '%d', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'processing', nlabel => 'watchers.processing.duration.milliseconds', set => {
{ label => 'country-processing', nlabel => 'watchers.processing.duration.milliseconds', set => {
key_values => [ { name => 'processing' } ],
output_template => 'API Processing duration: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'users', nlabel => 'users.count', set => {
{ label => 'country-users', nlabel => 'watchers.users.count', set => {
key_values => [ { name => 'users' } ],
output_template => 'Connected users: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'waiting-time-avg', nlabel => 'watchers.waiting.time.milliseconds', set => {
{ label => 'country-waiting-time-avg', nlabel => 'watchers.waiting.time.milliseconds', set => {
key_values => [ { name => 'waiting_time_avg' } ],
output_template => 'Waiting time avg: %.2f ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 },
],
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
]
}
}
];
$self->{maps_counters}->{dtt_spent} = [
{ label => 'dtt-spent', nlabel => 'watcher.dtt.spent.time.milliseconds', set => {
{ label => 'watcher-dtt-spent', nlabel => 'watcher.dtt.spent.time.milliseconds', set => {
key_values => [ { name => 'dtt_spent' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'DTT spent: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
@ -320,7 +320,7 @@ sub set_counters {
];
$self->{maps_counters}->{errors_prct} = [
{ label => 'errors-prct', nlabel => 'watcher.errors.percentage', set => {
{ label => 'watcher-errors-prct', nlabel => 'watcher.errors.percentage', set => {
key_values => [ { name => 'errors_prct' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'Errors: %.2f%%',
closure_custom_perfdata => $self->can('custom_usage_perfdata')
@ -329,7 +329,7 @@ sub set_counters {
];
$self->{maps_counters}->{full_network_time_spent} = [
{ label => 'full-network-time-spent', nlabel => 'watcher.network.spent.time.milliseconds', set => {
{ label => 'watcher-full-network-time-spent', nlabel => 'watcher.network.spent.time.milliseconds', set => {
key_values => [ { name => 'full_network_time_spent' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'Full network time spent: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
@ -338,7 +338,7 @@ sub set_counters {
];
$self->{maps_counters}->{loading_page} = [
{ label => 'loading-page', nlabel => 'watcher.loading.page.duration.milliseconds', set => {
{ label => 'watcher-loading-page', nlabel => 'watcher.loading.page.duration.milliseconds', set => {
key_values => [ { name => 'loading_page' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'Loading page duration: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
@ -347,7 +347,7 @@ sub set_counters {
];
$self->{maps_counters}->{pages} = [
{ label => 'pages', nlabel => 'watcher.pages.count', set => {
{ label => 'watcher-pages', nlabel => 'watcher.pages.count', set => {
key_values => [ { name => 'pages' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'Loaded pages: %d',
closure_custom_perfdata => $self->can('custom_usage_perfdata')
@ -356,7 +356,7 @@ sub set_counters {
];
$self->{maps_counters}->{processing} = [
{ label => 'processing', nlabel => 'watcher.processing.duration.milliseconds', set => {
{ label => 'watcher-processing', nlabel => 'watcher.processing.duration.milliseconds', set => {
key_values => [ { name => 'processing' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'API Processing duration: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
@ -365,7 +365,7 @@ sub set_counters {
];
$self->{maps_counters}->{redirect_time_avg} = [
{ label => 'redirect-time-avg', nlabel => 'watcher.redirect.time.milliseconds', set => {
{ label => 'watcher-redirect-time-avg', nlabel => 'watcher.redirect.time.milliseconds', set => {
key_values => [ { name => 'redirect_time_avg' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'Redirect time avg: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
@ -374,7 +374,7 @@ sub set_counters {
];
$self->{maps_counters}->{requests} = [
{ label => 'requests', nlabel => 'watcher.requests.count', set => {
{ label => 'watcher-requests', nlabel => 'watcher.requests.count', set => {
key_values => [ { name => 'requests' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
output_template => 'Requests: %s',
closure_custom_perfdata => $self->can('custom_usage_perfdata')
@ -383,8 +383,8 @@ sub set_counters {
];
$self->{maps_counters}->{sessions} = [
{ label => 'sessions', nlabel => 'watcher.sessions.count', set => {
key_values => [ { name => 'sessions' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
{ label => 'watcher-sessions', nlabel => 'watcher.sessions.count', set => {
key_values => [ { name => 'sessions' }, { name => 'watcher_name' }, { name => 'site_name' }, { name => 'gateway_name'} ],
output_template => 'Sessions: %s',
closure_custom_perfdata => $self->can('custom_usage_perfdata')
}
@ -392,8 +392,8 @@ sub set_counters {
];
$self->{maps_counters}->{srt_spent} = [
{ label => 'srt-spent', nlabel => 'watcher.srt.spent.time.milliseconds', set => {
key_values => [ { name => 'srt_spent' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
{ label => 'watcher-srt-spent', nlabel => 'watcher.srt.spent.time.milliseconds', set => {
key_values => [ { name => 'srt_spent' }, { name => 'watcher_name' }, { name => 'site_name' }, { name => 'gateway_name'} ],
output_template => 'SRT spent: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
}
@ -401,17 +401,17 @@ sub set_counters {
];
$self->{maps_counters}->{users} = [
{ label => 'users', nlabel => 'users.count', set => {
key_values => [ { name => 'connected_users' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
{ label => 'watcher-users', nlabel => 'watcher.users.count', set => {
key_values => [ { name => 'connected_users' }, { name => 'watcher_name' }, { name => 'site_name' }, { name => 'gateway_name'} ],
output_template => 'Connected users: %s',
closure_custom_perfdata => $self->can('custom_usage_perfdata')
}
},
}
];
$self->{maps_counters}->{waiting_time} = [
{ label => 'waiting-time', nlabel => 'watcher.waiting.time.milliseconds', set => {
key_values => [ { name => 'waiting_time' }, { name => 'watcher_name' }, { name => 'site_name'}, { name => 'gateway_name'} ],
{ label => 'watcher-waiting-time', nlabel => 'watcher.waiting.time.milliseconds', set => {
key_values => [ { name => 'waiting_time' }, { name => 'watcher_name' }, { name => 'site_name' }, { name => 'gateway_name'} ],
output_template => 'Waiting time: %.2f ms',
closure_custom_perfdata => $self->can('custom_usage_perfdata_ms')
}
@ -419,23 +419,18 @@ sub set_counters {
];
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'country:s' => { name => 'country'},
'isp:s' => { name => 'isp'},
'country:s' => { name => 'country' },
'isp:s' => { name => 'isp' },
'select-watcher-name:s' => { name => 'watcher_name' },
'select-site-name:s' => { name => 'site_name'},
'select-gateway-name:s' => { name => 'gateway_name'},
'wfa:s' => { name => 'wfa'}
'select-site-name:s' => { name => 'site_name' },
'select-gateway-name:s' => { name => 'gateway_name' },
'wfa' => { name => 'wfa' }
});
return $self;
@ -661,7 +656,6 @@ sub manage_selection {
$self->{output}->add_option_msg(short_msg => "No instances or results found.");
$self->{output}->option_exit();
}
}
1;
@ -696,53 +690,20 @@ Leave empty to get statistics from all countries, or specify particular country.
=item B<--isp>
Display statistics per ISP.
Display statistics per ISP.
Leave empty to get statistics from all ISP, or specify particular ISP.
=item B<--wfa>
Display statistics for watchers used by work-from-anywhere users.
Display statistics for watchers used by work-from-anywhere users.
=item B<--warning-errors-prct>
=item B<--warning-[country|isp|watcher]-*> B<--critical-[country|isp|watcher]-*>
Warning threshold for web browser errors (4xx and 5xx types) in percentage.
=item B<--critical-errors-prct>
Critical threshold for web browser errors (4xx and 5xx types) in percentage.
=item B<--warning-sessions>
Warning threshold for web sessions number.
=item B<--critical-sessions>
Critical threshold for web sessions number.
=item B<--warning-request>
Warning threshold for requests number.
=item B<--critical-request>
Critical threshold for requests number.
=item B<--warning-pages>
Warning threshold for requested pages by the application.
=item B<--critical-pages>
Critical threshold for requested pages by the application.
=item B<--warning-loading-page>
Warning threshold loading page duration in milliseconds.
=item B<--critical-loading-page>
Critical threshold for loading page duration in milliseconds.
Thresholds. Can be:
'dtt-spent', 'errors-prct', 'full-time-network-spent',
'sessions', 'srt-spent', 'requests', 'redirect-time-avg',
'loading-page', 'pages', 'processing', 'users', 'waiting-time-avg'.
=back

View File

@ -29,10 +29,9 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$self->{modes} = {
'list-watchers' => 'apps::monitoring::kadiska::mode::listwatchers',
'list-stations' => 'apps::monitoring::kadiska::mode::liststations',
'list-runners' => 'apps::monitoring::kadiska::mode::listrunners',
'list-targets' => 'apps::monitoring::kadiska::mode::listtargets',
'watcher-statistics' => 'apps::monitoring::kadiska::mode::watcherstatistics',
'nettracer-statistics' => 'apps::monitoring::kadiska::mode::nettracerstatistics'