Speedtest.edpnet.be Bash script

Google Docs graph of two weeks of speedtest.edpnet.be

Google Docs graph of two weeks of speedtest.edpnet.be

This script is for people using the Belgium provider EDPnet. I wrote it to get a couple of weeks worth of download speed data, because my download speed regulary drops dramatically. The script is meant to be run in the background by calling it with ./speedtest.sh &. It will start an infinite loop and do the speedtest.edpnet.be speedtest on a configurable interval (one hour defaultly). It uses curl, but if put in wget as well, just uncomment the wget line and comment out the curl line. It can easly be adjusted for most other providers download-speed-tests, just figure out which exact file you need to download for the test.

The output is in CSV format meant to be imported by Excel, Google docs etc.

An example report including a graph can be found here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/bash
# DESCRIPTION:
# Simple script to monitor your EDPnet ADSL connection speed by doing the speedtest.edpnet.be test on a set interval
# This script uses an infinite loop with a while loop that never ends, which is crude, but makes it easy to employ
# Output is in CSV format optimized for Excel import, script does some simple log numbering as well
 
# USAGE:
# Best is to run in it the background with: speedtest.sh  &
# Don't forget to kill (ps ax|grep speedtest.sh) it when your are done or it will run until the computer is restarted
 
# EXCEL IMPORT:
# In Excel do  File  Import  CSV  Finish. Or manually specify the comma seperator and double quotes as field markers
 
# VARIABLES
TEMPFILE=tempfile
# CSV file name, csv extension automatically appended as well as a log number
CSV=speedtest-log
SEPERATOR=","
# If you want you can change the interval at which the test is run (in seconds)
INTERVAL=3600
# Used for the infinite while loop
COUNTER=OMEGA
 
# Find logfile with highest number and determine the log number for this run
OLDNR=$(find . -name "$CSV*.csv" -maxdepth 1 | cut -d"." -f3 | sort -nr | head -n 1)
NR=$(($OLDNR + 1))
 
echo "Script running, infinite while loop in effect"
 
# Print header row and create log file
echo "\"Date and time\"$SEPERATOR\"Speed in Kbyte\""  > $CSV.$NR.csv
 
while [ $COUNTER = OMEGA ]; do
 
	# Execute the speedtest
	# Defaultly I use curl, but you can use wget as well. Just uncomment the one you want, and comment out the one you don't
	curl -A "Mozilla/5.0 Littlebighuman.com/edpspeedtest.sh 1.0" -s "http://speedtest.edpnet.be/speedtest4.php" -o TEMPFILE
	# wget -O$TEMPFILE "http://speedtest.edpnet.be/speedtest4.php" 2> /dev/null
 
	# Get the line with the data we need
	DATALINE=$(cat "$TEMPFILE" | awk '/Your result is/')
 
	# Empty TEMPFILE for the next while run
	cat /dev/null  > $TEMPFILE
 
	# Get the current time and date
	CURRENTDATE=$(date +"%d-%m-%Y %H:%M")
 
	# Get the speed in kbyte and replace the dot with a comma for Belgium international format
	SPEED=$(echo $DATALINE | awk '{print $5}' | sed 's/\./\,/g')
 
	# Output in CSV format
	echo "\"$CURRENTDATE\"$SEPERATOR\"$SPEED\""  >> $CSV.$NR.csv
 
	# Sleep
	sleep $INTERVAL
done
This entry was posted in Networking, Scripts and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">