Keeping your ISP Honest – a speed test

After months of grief at home about poor internet speeds & being in a typical family of too many wifi devices per person etc. etc. (the only person that’s not concerned in Honey my golden retriever)…..

I decided to try a new ISP with a Cable broadband offering. Big letters advertised you can get ‘up to’ 100Mbps down which is a far cry better than my current 8mbps. (You even could pay extra for the privilege of up to 100Mbps – a speed boost as they called it)

With speed boost- 100mbps

Without speed boost – 30mbps

So all got hooked up and indeed I could get 100mbps and life was rosy…. until….people started using it.

As I’m sure you’re aware – currently cable broadband in Oz is a hub system dependent on the number of users. So in short, with my ISP, if there are people (nearby) using the product, your service will suffer. Anyone else see the floored logic here…

So I thought to myself let’s do hourly speed checks as let’s see them stand by their word.

In my experience the current day organisation care about their sentiment analysis on social media – if they’re tracking good then great, if they’re not…then it’s trouble.

If my ISP lives up to their promise…then I’ll praise them, if not I’ll grumble. Let’s see how this experiment goes…. 🙂

The short version

  • I wrote some Powershell that executes a command line to run a speed test against speedtest.net (credit goes to sivel, https://github.com/sivel/speedtest-cli & Zack Peters – https://github.com/zpeters/speedtest)
  • I next grab the results and insert them into an Azure Storage Table for Microsoft Power BI to crunch over. (I created a Power BI report first – tweaked it here and there)
  • Embedded the Report on this page….

 

My ISP Speeds so far (had alot of trouble trying to get this into an iframe/embedded object on my blog – hopefully it’ll happen soon)

dismalISP.png
We’re a far cry off 100Mbps at the moment… Average is around 25Mbps
reportDash.png
Few details around the metrics collected – pretty simple for a first cut at the Power BI dashboard.

 

Running the speedtest

1. Download the speed test windows exe from https://github.com/zpeters/speedtest

2. Copy the EXE to C:\Utils & rename it to speedtest.exe (this are just to fit my script below, feel free to adjust whichever way you like)

3. Install Azure Powershell SDK

4. Copy the Powershell below into a file called c:\utils\speedtest.ps1

5. Execute the Powershell as a Scheduled task in a batch file (if you like)

Enjoy….

 

# Powershell

#C:\utils\speedtest.exe -a avg -r -q > c:\utils\speedlog.txt

function InsertRow($table, [string]$srv,[double]$ping,[double]$AvgDLSpeed, [double]$AvgUPSpeed)
{
$partitionKey = ‘speed’
$rowKey = (Get-Date).Ticks
$entity = New-Object “Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity” $partitionKey, $rowKey
$d = Get-Date -format s
$entity.Properties.Add(“ExeDateTime”, $d)
$entity.Properties.Add(“PingSpeed”,$ping)
$entity.Properties.Add(“DLSpeed”,$AvgDLSpeed)
$entity.Properties.Add(“UPSpeed”,$AvgUPSpeed)
$entity.Properties.Add(“Server”,$srv)

$result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::Insert($entity))
}

$StorageAccountName = “<your storage account name>”
$StorageAccountKey = “<your storage account key>”

$context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
$tablename = “<your tablename>”  #nb: lowercase
$table = Get-AzureStorageTable $tablename -Context $context -ErrorAction Ignore #I had issues here on a storage V2.0 acct – this line returned not null even though the table wasn’s created. Ran the new table line manually
if ($table -eq $null)
{
New-AzureStorageTable $tablename -Context $context
}

# Setup the Process startup info
$installDir = ‘c:\utils’
$fname = “$installDir\speedtest.exe”
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $fname
$pinfo.Arguments = “-a avg -r”
$pinfo.UseShellExecute = $false
$pinfo.CreateNoWindow = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.RedirectStandardError = $true

#start the command
echo $pinfo.FileName ” starting….”

# Create a process object using the startup info
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $pinfo

# Start the process
$process.Start() | Out-Null

# Wait a while for the process to do something
sleep -Seconds 5
$t = ”;
# If the process is still active kill it
if (!$process.HasExited) {
$t = $t + ‘.’;
write-host “$t” -NoNewline
sleep -Seconds 5
}
Write-Host ”
Write-Host ‘Getting output.’

# get output from stdout and stderr
$stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd()
if (($stdout -ne $null) -and ($stdout -ne ”))
{
Write-Host “Output: $stdout”
$parts = $stdout.Split(‘|’)
if ($parts.Length -eq 6) #we have all the data
{
$srvName=$parts[1] + ‘|’ + $parts[2]
InsertRow $table -srv $srvName -ping $parts[3] -AvgDLSpeed $parts[4] -AvgUPSpeed $parts[5]
}
}
# check output for success information, you may want to check stderr if stdout if empty
if ($stdout.Contains(“Error”)) {
# exit with errorlevel 0 to indicate success
exit 1
} else {
# exit with errorlevel 1 to indicate an error
exit 0
}

 

Advertisements

3 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s