Skip to content

Instantly share code, notes, and snippets.

@dr-kd
Last active July 31, 2016 02:29
Show Gist options
  • Save dr-kd/0ed91ab68c14ae70a48848a6e0d0bdd7 to your computer and use it in GitHub Desktop.
Save dr-kd/0ed91ab68c14ae70a48848a6e0d0bdd7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl;
use warnings;
use strict;
use IPC::System::Simple qw/capture/;
use DateTime;
my $now = DateTime->now;
my $st = '/usr/local/bin/speedtest-cli'; # via pip-install speedtest-cli
my $res = capture "$st";
my ($ping) = $res =~ /(\d+\.\d+) ms/ms;
my ($download) = $res =~ /Download: (\d+\.\d+) /ms;
my ($upload) = $res =~ /Upload: (\d+\.\d+) /ms;
my ($server) = $res =~ /Testing from (\w+)/ms;
print "$now,$ping,$download,$upload,$server\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment