I just had a Eureka! moment:
Code:
wget domain.com/testfile -O /dev/null 2>&1 | grep saved | sed 's/\(s)\).*/\1/' >> /root/Desktop/speedtest.txt
Speedtest.txt output:
Each time it runs it adds a new line, and it's all on an easy to reach file on my desktop.
My crontab -e reads as follows:
Code:
*/5 * * * * wget domain.com/mytestfile -O /dev/null 2>&1 | grep saved | sed 's/\(s)\).*/\1/' >> /root/Desktop/speedtest.txt
I figured why not get good use out of that unmetered connection and run it every 5 minutes, after a few days it should provide an accurate picture of how fast my connection is over time.
Now, I ran into my usual problem with linux: Any time I solve a tough challenge, instead of stopping and congratulating myself, I think 'How can I make this even better?' Since I am already collecting accurate, easily formatted data showing a change or trend over time, the answer was obvious: Make it a graph! The best way to do this was to send it to excel by putting it into csv form with the required format. I wrote the following string to do so:
Code:
cat /root/Desktop/speedtest.txt | sed 's/:.. / /' | sed 's/ (/,/' |sed 's/ MB\/s)//' > /tmp/speedtest.tmp ; echo "Time:,Speed (MB/s):" | cat - /tmp/speedtest.tmp > /root/Desktop/speedtest.csv ; rm - f /tmp/speedtest.tmp
This changed this:
Quote:
01:15:10 (11.2 MB/s)
01:20:10 (11.2 MB/s)
01:25:10 (11.2 MB/s)
01:30:10 (11.2 MB/s)
01:35:10 (11.2 MB/s)
01:40:10 (11.1 MB/s)
01:45:10 (11.2 MB/s)
01:50:10 (11.2 MB/s)
|
Into this:
Quote:
Time:,Speed (MB/s):
01:15,11.2
01:20,10.2
01:25,11.2
01:30,11.2
01:35,11.2
01:40,11.1
01:45,11.2
01:50,11.2
|
With a few seconds worth of formatting in Excel, that turned into this beautiful graph:
http://i.imgur.com/6CPDZ.png
Lastly, I added the changes to my crontab file:
Code:
*/5 * * * * wget domain.com/testfile -O /dev/null 2>&1 | grep saved | sed 's/\(s)\).*/\1/' >> /root/Desktop/speedtest.txt ; cat /root/Desktop/speedtest.txt | sed 's/:.. / /' | sed 's/ (/,/' | sed 's/ MB\/s)//' > /tmp/speedtest.tmp ; echo "Time:,Speed (MB/s):" | cat - /tmp/speedtest.tmp &> /root/Desktop/speedtest.csv ; rm -f /tmp/
And I'm set! Whenever I want to check the speed logs for the past few days, I simply FTP it over and open it in Excel then make a graph out of it.
This illustrates my simultaneous love and hate for Linux. I love being able to do whatever I want in it; I hate getting sucked into it and emerging 2 hours later without any real work done on it. It's an awesome server\tweaking OS, but I can't see myself using something besides Windows for my work PC.
On the other hand, I'm quite proud of what I accomplished - I'm virtually clueless when it comes to the shell, and it took a LOT of googling and reading to, say, find out that the ; command waits for the current operation to finish before moving on to the next task. Basic stuff that linux gurus take for granted is painful to find out on demand!