Knowledgebase:
Logging download speed and latency with Bash
Posted by Jared Thomas on 18 December 2015 02:43 PM

This is a quick and dirty script that logs the current download speed and latency to a text file. To use it, copy the script in to your home folder, adjust the log variable to suit your environment and add it to cron on some reasonable interval such as every 10 minutes. This script does not rotate the log in any way so make sure you don't leave it on indefinitely or you will end up with a massive log file.

#!/bin/bash
# Variables
datetime=$(date +%c)
log=/home/jared/netspeed.log
# Execution
echo $datetime >> $log
echo "scale=2; `curl -s -w "%{speed_download}" http://speedtest.wdc01.softlayer.com/downloads/test10.zip -o test.zip` / 131072" | bc | xargs -I {} echo {}Mb\/s >> $log
ping -c 10 8.8.8.8 >> $log
echo -en '\n' >> $log
exit 0

(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).