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

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{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{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{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; my $multiple = scalar(keys %filters);
my @filter = ();
if (keys %filters > 1){ foreach my $filter_name (keys %filters) {
foreach my $filter_name (keys %filters){ my @entry;
if ($filter_name eq 'wfa'){ if ($filter_name eq 'wfa') {
unshift(@filter, ["=", "wfa", \1]) if defined($filters{$filter_name}); @entry = $multiple > 1 ? (["=", "wfa", \1]) : ("=", "wfa", \1);
next; } else {
} @entry = $multiple > 1 ? (["=", $filter_name, ['$', $filters{$filter_name}]]) : ("=", $filter_name, ['$', $filters{$filter_name}]);
unshift(@filter, ["=", $filter_name,["\$", $filters{$filter_name}]]);
} }
unshift(@filter, @entry);
}
if ($multiple > 1) {
unshift(@filter, 'and'); 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 { sub request_api {
@ -318,4 +316,4 @@ Set timeout in seconds (Default: 10).
=back =back
=cut =cut

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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