Coder Social home page Coder Social logo

lifailon / ookla-speedtest-api Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 17.89 MB

Module creating metrics measurements Internet speed to mode cli (no use dependencies). Using native API.

License: Apache License 2.0

PowerShell 100.00%
internet-explorer native-api ookla-speedtest powershell-module speedtest-cli rest-api internet-speed-test api com-object powershell

ookla-speedtest-api's Introduction

Ookla-SpeedTest-API

GitHub Release NuGet Version GitHub top language GitHub License

Module for get metrics measurements Internet speed to mode cli (no use dependencies) and output to PSObject format or log file. Data collection resource: speedtest.net (dev Ookla).

๐Ÿ“š Used methods

  • Using native API method (via COM Object InternetExplorer) for web function start
  • Using REST API GET method (via Invoke-RestMethod) for parsing JSON report

๐Ÿš€ Install/Update

โœ”๏ธ Works in PSVersion 5.1
โŒ IE to PowerShell 7.3 not supported

Use the NuGet package manager:

Install-Module Ookla-SpeedTest -Repository NuGet

๐Ÿ’ก You must have a NuGet repository registered:

Get-PackageProvider # check that the nuget packet provider is installed
Find-PackageProvider # display all available package managers
Install-PackageProvider nuget # install the nuget package manager
Set-PackageSource nuget -Trusted # allow packages to be installed from the specified source
Find-Package Ookla-SpeedTest # search for packages by name in all managers
Install-Module Ookla-SpeedTest -Scope CurrentUser # install the module for the current user

For install or update module from the GitHub repository (used the script Deploy-Invoke-SpeedTest.ps1) use the command in the PowerShell console:

Invoke-Expression(New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/Lifailon/Ookla-SpeedTest-API/rsa/Scripts/Deploy-Invoke-SpeedTest.ps1")

๐Ÿ”” Module Invoke-SpeedTest

PS C:\Users\Lifailon> $ookla = Invoke-SpeedTest -LogWrite

date               : 08.05.2023 11:36:10
id                 : 14708271987
connection_icon    : wireless
download           : 33418
upload             : 35442
latency            : 15
distance           : 50
country_code       : RU
server_id          : 2707
server_name        : Bryansk
sponsor_name       : DOM.RU
sponsor_url        :
connection_mode    : multi
isp_name           : Resource Link
isp_rating         : 4.0
test_rank          : 63
test_grade         : B-
test_rating        : 4
idle_latency       : 17
download_latency   : 116
upload_latency     : 75
additional_servers : {@{server_id=8191; server_name=Bryansk; sponsor_name=SectorTelecom.ru}, @{server_id=46278; server_
                     name=Fokino; sponsor_name=Fokks - Promyshlennaya avtomatika Ltd.}, @{server_id=18218; server_name=
                     Bryansk; sponsor_name=RIA-link Ltd.}}
path               : result/14708271987
hasSecondary       : True

PS C:\Users\Lifailon> $ookla.additional_servers

server_id server_name sponsor_name
--------- ----------- ------------
     8191 Bryansk     SectorTelecom.ru
    46278 Fokino      Fokks - Promyshlennaya avtomatika Ltd.
    18218 Bryansk     RIA-link Ltd.

๐ŸŽ‰ Example

Result to UI: https://www.speedtest.net/result/14708271987

Image alt

๐Ÿ“‘ Output log to console

PS C:\Users\Lifailon> Invoke-SpeedTest -LogRead | ft

Date       Time     Download    Upload      Ping
----       ----     --------    ------      ----
05/08/2023 02:10:32 36.293 Mbit 34.832 Mbit 16 ms
05/08/2023 02:39:18 34.623 Mbit 34.623 Mbit 18 ms
05/08/2023 02:49:01 33.530 Mbit 35.573 Mbit 16 ms
05/08/2023 10:50:50 32.638 Mbit 37.382 Mbit 15 ms
05/08/2023 11:20:33 37.402 Mbit 39.780 Mbit 16 ms
05/08/2023 11:21:34 36.034 Mbit 35.835 Mbit 16 ms
05/08/2023 11:33:04 32.101 Mbit 32.742 Mbit 18 ms
05/08/2023 11:36:10 33.418 Mbit 35.442 Mbit 17 ms
...

๐Ÿ“Š PowerShell + InfluxDB + Grafana

Create Service

Download script: SpeedTestTo-InfluxDB.ps1 (change the IP-address and database name for InfluxDB)
Download NSSM
Copy files to folder: C:\NSSM\

$powershell_Path = (Get-Command powershell).Source
$NSSM_Path = "C:\NSSM\NSSM-2.24.exe"
$Script_Path = "C:\NSSM\SpeedTestTo-InfluxDB.ps1"
$Service_Name = "SpeedTestTo-InfluxDB"
& $NSSM_Path install $Service_Name $powershell_Path -ExecutionPolicy Bypass -NoProfile -f $Script_Path
Get-Service $Service_Name | Start-Service
Get-Service $Service_Name | Set-Service -StartupType Automatic

Get-Service $Service_Name | select Status,Name,StartType

Status Name                 StartType
 ------ ----                 ---------
Running SpeedTestTo-InfluxDB Automatic

View Data

SELECT * FROM "speedtest" WHERE time > now() - 40m

Image alt

Add to Dashboard

SELECT download,upload FROM speedtest

Image alt

Image alt

Changelog:

09.07.2023: Added script create service for dashboard Grafana from the InfluxDB
19.07.2023: Debug for process stoppage (added block finally) and disable check certificate to IE settings

ookla-speedtest-api's People

Contributors

lifailon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.