Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-31-2010, 12:48 AM   #1
LQ Newbie
Registered: Jun 2010
Posts: 4

Rep: Reputation: 0
Monitoring internet connection speed

I'm trying to find a good host for my site, and I've been trying to get one with a fast, reliable connection - I frequently use it as a proxy server for various areas, and since my connection is frequently a 50 Mb or 100 Mb line, I need a fast network connection so it doesn't slow down too much when I switch to the proxy server.

At the moment, I've narrowed it down to a couple of providers that are all within a few hops and <6ms away from my main location; it pretty much comes down to connection speed. One in particular that I'm trialing offers an metered 100\100 connection at a good price, so I'm hoping to go with them, but I want to make sure the connection is solid and doesn't drop to a much lower speed during the day if they are sharing it among many users.

I have a pretty simple speed test procedure - I use wget on a 1GB file hosted on a backbone with a 1GB connection, and see how fast it downloads. For now, it's sticking at a steady 11.2 MB\s or 90 Mb\s, which is fast enough for me, but I need to make sure it can maintain that speed even in times of heavy usage.

Basically, I need a script that runs wget every half hour and logs the output and time in a reasonably readable format. It's probably something simple enough to do, but I'm just learning my way around the linux command shell, so some simple instructions on how to create and run such a script would be great [CentOS 5]. I have full root access to the server and I'm the only user on it if it matters.
Old 07-31-2010, 01:24 AM   #2
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,125

Rep: Reputation: 97
I would point you at crontab for setting it up for every half an hour.

As far as I can think of...

wget &> /tmp/downloadtest.txt

would place the output into a single file, how to manipulate the data out of the data I am not sure how to do with bash scripting myself (I know other programming and scripting languages I myself could do it with but that entails going into much deeper coding, I am fairly sure a small bash script could easily handle this) but a substring command would likely be needed to pull out the actual download speed (given that it will be the characters before either MB/s or KB/s, potentially GB/s will be seen more in the future, as well as checking to ensure the download did not actually just fail).

After that a simple rm /tmp/downloadtest.txt to ensure it doesn't get overwritten.

What I might else wise suggest is there may already be a utility or service around that can do this for you, did you check for this possibility?

Last edited by r3sistance; 07-31-2010 at 01:30 AM.
Old 07-31-2010, 03:31 AM   #3
LQ Newbie
Registered: Jun 2010
Posts: 4

Original Poster
Rep: Reputation: 0
I just had a Eureka! moment:
wget -O /dev/null 2>&1 | grep saved | sed 's/\(s)\).*/\1/' >> /root/Desktop/speedtest.txt
Speedtest.txt output:
00:53:44 (11.2 MB/s)
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:
*/5 * * * * wget -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:

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:
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:
Time:,Speed (MB/s):
With a few seconds worth of formatting in Excel, that turned into this beautiful graph:

Lastly, I added the changes to my crontab file:
*/5 * * * * wget -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!
Attached Thumbnails
Click image for larger version

Name:	testcsv.png
Views:	1
Size:	97.0 KB
ID:	4213  


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Connection Speed sucram2g Linux - Networking 4 04-21-2010 10:23 PM
Internet Connection monitoring nmansour Linux - Networking 2 11-07-2007 01:47 AM
internet speed monitoring s/w emailssent Linux - Software 4 09-15-2004 02:56 AM
Internet connection progam permissions? any monitoring software? Mad Malc Linux - Security 4 08-08-2004 04:53 PM
Is there a tool to monitor Internet connection speed and also network speed? xleft4dexy Linux - Networking 4 10-14-2003 11:29 PM

All times are GMT -5. The time now is 09:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration