ethered has asked for the wisdom of the Perl Monks concerning the following question:
For some time now my internet connection have been unreliable to say the least. I'm paying for a 50/50 connection, but I'm seeing a steady 23/18 on average(mbps). As well as some pretty annoying latency issues... So! I want to monitor this over time, to build a waterproof case for myself.
I want to use speedtest-cli on my Ubuntu server, and by cron make it do a speedtest every 12 hours. After asking internet for advice I ended wanting to do this with Perl.
open speedtest,"speedtest-cli --simple |" or die "Cannot open speedtes +t"; $datestring = localtime(); while (<speedtest>) { if (/Download\:[0-9\.]*)/) { $speed=$1; print "$datestring : Download $speed +n"; } elsif (/Upload\:[0-9\.]*)/) { $speed=$1; print "$datestring : Upload $speed +n"; } }
...which works fine except for the fact that it doesn't print the results, rather just time/date and "Download"/"Upload".
Also; I want to store this in one .txt file, and I'm thinking that I'll do that in my crontab. Would it store each result in a new line in that file or overwrite it? Any ideas on how to do this?
Thank you for any and all help regarding this :-) PS: I can verify that the script starts speedtest-cli, and that it prints out time/date.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running speedtest-cli with Perl and cron
by Anonymous Monk on Dec 11, 2014 at 16:17 UTC | |
by ethered (Initiate) on Dec 12, 2014 at 06:41 UTC | |
|
Re: Running speedtest-cli with Perl and cron
by GotToBTru (Prior) on Dec 11, 2014 at 16:13 UTC | |
by ethered (Initiate) on Dec 12, 2014 at 06:44 UTC | |
|
Re: Running speedtest-cli with Perl and cron
by Tux (Canon) on Dec 12, 2014 at 09:44 UTC | |
by Discipulus (Canon) on Dec 12, 2014 at 10:05 UTC | |
|
Re: Running speedtest-cli with Perl and cron
by NetWallah (Canon) on Dec 12, 2014 at 07:01 UTC | |
by ethered (Initiate) on Dec 12, 2014 at 09:13 UTC | |
by NetWallah (Canon) on Dec 12, 2014 at 21:48 UTC | |
|
Re: Running speedtest-cli with Perl and cron
by Discipulus (Canon) on Dec 12, 2014 at 09:23 UTC |