Ookla Speedtest
After a few failed attempts to get this working on Windows via Powershell (works, but too inaccurate), I punted and used speedtest-cli. If I can replicate that into Groovy, then perhaps it could be universal, but Linux-only for now.
4CN9AA
This will be held for code review, but it is very simple code :).
mnagel
Posted 7 years ago·Last reply 7 years ago
6 comments
Cole McDonald
·7 years agoI changed the first If () {} to test the correct variable (was $site, which isn't represented anywhere else in the script). Then I cleaned the code up a bit and lined everything up... OCD is both great and horrible for programming.
Cole McDonald
·7 years agoSeems to work to get the same data as the .net web client the other is implementing. This both implements the download test and retrieves the returned code to be parsed for any tokens that would allow it to perform the push... just have to figure out the request they're building to piece the next URL or REST request together.
mnagel
OP7 years ago@Cole McDonald Sure, no problem -- see below. The Ookla one is not much better in reality because the web method is not as accurate as the application socket method, but at least it tried to do bidirectional testing.
I can't claim credit for this, I found it and modified a bit to work in LM. I set the mirror site as a property since auto-selection does not work with testmy.net.
Mark
$size = 50;
$mirror = "##speedtest.testmy.mirror##";
if ($site -eq "") {
$url = "https://testmy.net/dl-${size}MB"
}
else {
$url = "https://${mirror}.testmy.net/dl-${size}MB"
}
$path = "Out-Null"
$WebClient = New-Object System.Net.WebClient
$mbps = "{0:N2}" -f (($size/(Measure-Command {$Request=Get-Date; $WebClient.DownloadFile( $url, $path )}).TotalSeconds) * ?
Write-Host "Mbps="$mbps
Cole McDonald
·7 years agomnagel… would you mind if I took a peek at your powershell? Second set of eyes and all that.
Michael Rodrigues
·7 years agoReviewed.
You weren't kidding about simple code.