Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(plugin) apps::monitoring::speedtest - use Ookla version #4563

Merged
merged 2 commits into from Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 32 additions & 15 deletions src/apps/monitoring/speedtest/mode/internetbandwidth.pm
Expand Up @@ -26,28 +26,40 @@ use strict;
use warnings;
use JSON::XS;

sub prefix_global_output {
sub prefix_ping_output {
my ($self, %options) = @_;

return 'speedtest ';
return 'ping ';
}

sub set_counters {
my ($self, %options) = @_;

$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }
{ name => 'ping', type => 0, cb_prefix_output => 'prefix_ping_output', skipped_code => { -10 => 1 } },
{ name => 'bandwidth', type => 0, skipped_code => { -10 => 1 } }
];

$self->{maps_counters}->{global} = [
{ label => 'ping-time', nlabel => 'ping.time.milliseconds', set => {
key_values => [ { name => 'ping' } ],
output_template => 'ping time: %d ms',
$self->{maps_counters}->{ping} = [
{ label => 'ping-latency', nlabel => 'ping.latency.milliseconds', set => {
key_values => [ { name => 'latency' } ],
output_template => 'latency: %.3f ms',
perfdatas => [
{ template => '%.3f', unit => 'ms', min => 0 }
]
}
},
{ label => 'ping-jitter', nlabel => 'ping.jitter.milliseconds', set => {
key_values => [ { name => 'jitter' } ],
output_template => 'jitter: %.3f',
perfdatas => [
{ template => '%.3f', min => 0 }
]
}
}
];

$self->{maps_counters}->{bandwidth} = [
{ label => 'bandwidth-download', nlabel => 'internet.bandwidth.download.bitspersecond', set => {
key_values => [ { name => 'download' } ],
output_template => 'download: %s %s/s',
Expand Down Expand Up @@ -83,8 +95,8 @@ sub manage_selection {
my ($self, %options) = @_;

my ($output) = $options{custom}->execute_command(
command => 'speedtest-cli',
command_options => '--json'
command => 'speedtest',
command_options => '--format=json'
);

my $decoded;
Expand All @@ -95,10 +107,15 @@ sub manage_selection {
$self->{output}->add_option_msg(short_msg => 'Cannot decode response');
$self->{output}->option_exit();
}
$self->{global} = {
ping => $decoded->{ping},
download => $decoded->{download},
upload => $decoded->{upload}

$self->{ping} = {
latency => $decoded->{ping}->{latency},
jitter => $decoded->{ping}->{jitter}
};

$self->{bandwidth} = {
download => $decoded->{download}->{bytes},
upload => $decoded->{upload}->{bytes}
};
}

Expand All @@ -110,14 +127,14 @@ __END__

Check internet bandwidth.

Command used: speedtest-cli --json
Command used: speedtest --format=json

=over 8

=item B<--warning-*> B<--critical-*>

Thresholds.
Can be: 'ping-time', 'bandwidth-download', 'bandwidth-upload'.
Can be: 'ping-jitter', 'ping-latency', 'bandwidth-download', 'bandwidth-upload'.

=back

Expand Down