Speedtest-cli Internet Up-/Downlink Measurement Integration

Im seeing a high internet usage to speedtest related sites running twice a day - is there a way to tone down the test size? windering if this is the 120*1000 in the script?

The 120*1000 is the time-out, not the size of the test size (120 seconds * 1000 milliseconds). AFAIK the test size is automatically determined based on how fast the connection is (faster connection higher payload, slower connection lower payload)

I too had this. Found that if I only run it once a day the usage is halved :blush:

I all seriousness, run it cli to see options but as said, I think its automatic.

Hi,
can’t install the Speedtest, getting this error:

[12:06:13] openhabian@openhab:~$ sudo apt-get install python-setuptools
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-setuptools is already the newest version (40.8.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
[12:06:25] openhabian@openhab:~$ sudo easy_install speedtest-cli
sudo: easy_install: command not found

Any advice?

why don’t you try:

sudo apt-get install speedtest-cli ?

1 Like

Thanks, wasn’t in my mind…

And did it work?

Yes, perfectly

1 Like

just figured out that the path is wrong if i installed speedtest with apt-get, can somebody tell me whats the right path for the rule

2019-08-18 22:00:00.050 [INFO ] [arthome.model.script.speedtest.rules] - --> speedtest executed...

2019-08-18 22:00:00.128 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "/usr/local/bin/speedtest-cli" (in directory "."): error=2, No such file or directory)

2019-08-18 22:00:00.166 [ERROR] [arthome.model.script.speedtest.rules] - --> speedtest failed. Output:

If i do sudo speedtest-cli its works in the command interface

[sudo] password for openhabian:
Retrieving speedtest.net configuration...
Testing from O2 Deutschland (77.13.178.38)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by SysEleven GmbH (Berlin) [2.81 km]: 8.717 ms
Testing download speed................................................................................
Download: 94.17 Mbit/s
Testing upload speed......................................................................................................
Upload: 3.80 Mbit/s

On Debian10 Buster this worked for me:

sudo apt-get install python3-pip
sudo pip3 install speedtest-cli

I use speed test like this

2 Likes

Looks very nice!
Do you dare publishing your code?

Hi there,

today i have a little question that is a bit off topic.

After updating my speedtest server to Debian Buster i got a strange behaviour. The download rates are in the same range as before. The upload rates are dropped significat to about 3 MBit from aboz 25MBit. i tried this on different Buster installations, but this is always the same. On a Debian Stretch installation i measure the full power.

Does anyone else has the same problem?

Thanks Thomas

Thats pretty. Can you share sitemap and graph? :slight_smile:

Hi Allen,
I’ve got the same problem with the speedtest. Could you give me a little bit more information how you fixed this? I’m using shelly and a vpn to ssh into the ubuntu machine with openhab.(when i’am not at home, normally using terminal at home on the mac)

Best regards😁

sent you a message.
will share my files that i used and it works like that for me ?
if you can give me that details i might be able to help.
i use mac and teamviewer if i am of site to connect to my ubuntu server at home.

Regards

a lot is necessary to get it all to this stage

Would ne nice if you could Share this to the Community, I think further People are interested in the Solution…

TimeLine Speed Test Picker and Resultant graphing

this has been done on linux ubuntu, which may affect some of the paths and scripts ( speedtest )

This will have many edits, bear with me, I did not write hardly any code, just took
it all from this most excellent and helpful community

Items you will need working :

Timeline picker, Note Picker version ( there is a very useful Display only Version )

Persistence for the graphing,so the system can remember your data to graph and so many many other good things

https://www.openhab.org/addons/persistence/rrd4j

i will load my setups for everyone to see. it was only so he could check. as i also had a simple fault.
all that was wrong was the location in the rule . once he fixed that it worked 100%

Items file :

Group Speedtest <"network-icon"> (Home)

String      SpeedtestSummary        "Speedtest [%s]"                                       <"speedtest_network">       (gSpeedtest)
Number      SpeedtestResultPing     "Ping [%.3f ms]"                                       <"speedtest_next5">         (gSpeedtest)
Number      SpeedtestResultDown     "Downlink [%.2f Mbit/s]"                               <"speedtest_download">      (gSpeedtest)
Number      SpeedtestResultUp       "Uplink [%.2f Mbit/s]"                                 <"speedtest_upload">        (gSpeedtest)
String      SpeedtestRunning        "Speedtest running ... [%s]"                           <"speedtest_new">           (gSpeedtest)
Switch      SpeedtestRerun          "Start manually"                                       <"speedtest_reload2">       (gSpeedtest)
DateTime    SpeedtestResultDate     "Last executed [%1$td.%1$tm.%1$tY, %1$tH:%1$tM Uhr]"   <"speedtest_problem4">      (gSpeedtest)

Rule file :

val String filename = "speedtest.rules"

rule "Speedtest init"
when
    System started
then
    createTimer(now.plusSeconds(195)) [|
        if (SpeedtestRerun.state == NULL) SpeedtestRerun.postUpdate(OFF)
        if (SpeedtestRunning.state == NULL) SpeedtestRunning.postUpdate("-")
        if (SpeedtestSummary.state == NULL || SpeedtestSummary.state == "")
            SpeedtestSummary.postUpdate("⁉ (unknown)")
    ]
end
rule "Speedtest"
when
    //Time cron "0 0 5,13 * * ?" or
    Time cron "0 0 * * * ?" or
    Item SpeedtestRerun received command ON
then
    logInfo(filename, "--> speedtest executed...")
    SpeedtestRunning.postUpdate("Measurement in progress...")

    // update timestamp for last execution
    SpeedtestResultDate.postUpdate(new DateTimeType())

    // execute the script, you may have to change the path depending on your system
    var String speedtestCliOutput = executeCommandLine("/usr/bin/speedtest-cli@@--simple", 120*1000)

    // for debugging:
    //var String speedtestCliOutput = "Ping: 43.32 ms\nDownload: 21.64 Mbit/s\nUpload: 4.27 Mbit/s"
    //logInfo(filename, "--> speedtest output:\n" + speedtestCliOutput + "\n\n")

    SpeedtestRunning.postUpdate("data analysis...")

    // starts off with a fairly simple error check, should be enough to catch all problems I can think of
    if (speedtestCliOutput.startsWith("Ping") && speedtestCliOutput.endsWith("Mbit/s")) {
        var String[] results = speedtestCliOutput.split("\\r?\\n")
        var float ping = new java.lang.Float(results.get(0).split(" ").get(1))
        var float down = new java.lang.Float(results.get(1).split(" ").get(1))
        var float up   = new java.lang.Float(results.get(2).split(" ").get(1))
        SpeedtestResultPing.postUpdate(ping)
        SpeedtestResultDown.postUpdate(down)
        SpeedtestResultUp.postUpdate(up)
        SpeedtestSummary.postUpdate(String::format("ᐁ  %.1f Mbit/s  ᐃ %.1f Mbit/s (%.0f ms)", down, up, ping))
        SpeedtestRunning.postUpdate("-")
        logInfo(filename, "--> speedtest finished.")
    } else {
        SpeedtestResultPing.postUpdate(0)
        SpeedtestResultDown.postUpdate(0)
        SpeedtestResultUp.postUpdate(0)
        SpeedtestSummary.postUpdate("(unknown)")
        SpeedtestRunning.postUpdate("Error during execution")
        logError(filename, "--> speedtest failed. Output:\n" + speedtestCliOutput + "\n\n")
    }
    SpeedtestRerun.postUpdate(OFF)
end

// vim: syntax=Xtend

you just need to check and change where you did the installation of speedtest-cli.

1 Like