in reply to Running speedtest-cli with Perl and cron
Here;s my contribution - this code returns a comma-separated list that can eventually be graphed by a spreadsheet program.
Output:use strict; use warnings; open my $speedtest,"speedtest-cli --simple |" or die "Cannot open spee +dtest:$!"; my %speed = (DATETIME => '"' . GetDateTime()->{datetime} . '"'); while (<$speedtest>) { next unless m/(\w+): ([\d\.]+)/; $speed{$1} = $2; } close $speedtest; print join(",",map {$speed{$_}} qw|DATETIME Download Upload|),"\n"; sub GetDateTime{ local $_={}; @$_{qw|sec min hour mday mon year wday yday isdst|} =localtime(tim +e); $_->{year}+=1900; $_->{mon}+=1; $_->{yyyymmdd} = sprintf "%04d-%02d-%02d", @$_{qw|year mo +n mday|}; $_->{hhmm} = sprintf "%02d:%02d", @$_{qw|hour mi +n|}; $_->{datetime} = $_->{yyyymmdd} . " " . $_->{hhmm}; return $_ }
"2014-12-11 22:58",53.79,7.19
"You're only given one little spark of madness. You mustn't lose it." - Robin Williams
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running speedtest-cli with Perl and cron
by ethered (Initiate) on Dec 12, 2014 at 09:13 UTC | |
by NetWallah (Canon) on Dec 12, 2014 at 21:48 UTC |