Node-Red Flow to Monitor Internet Speeds with Speedtest-cli

Speedtest-cli is a command line tool by Ookia which is available for Windows,Linux and Mac.

The install instructions are available here and here.

Because I use Python and Speedtest-cli is written in python I used the standard Pip install method on windows and my Raspberry Pi.



pip install speedtest-cli

Using Speedtest-cli From the Command Line

Before you try to use speedtest-cli tool in node-red then you should run it from the command line to check it works and to test out the options that you want to use.

The Gitub page also has a full list of the command line options but you can get them using the command.

speedtest-cli --help

The options that you might find useful are

  • –json -output as JSON
  • –server test against a specific server

Below is a screen shot of the command using the default options:

speedtest-cli-1

Below is a screen shot of the command using the –server and –json options:

speedtest-cli-2

The json option is very useful when you want to pass the data into a program as we do with node-red.

Node-Red Speed Test Flow

node-red-exec-nodeTo run it in node red we use the exec node which allows us to run external commands.

Here is a screen shot of the node configuration; notice how the command line options are passed to the command. Notice the json option

node-red-external-command-speedtest

The node has three outputs

  1. Standard Output
  2. Standard Error
  3. Return Code.

The command results are taken from output 1.

You can use output 3 to determine if the command succeeded or not. A value of 0 is good.

This is what the flow looks like.

I’ve added debug node so I can show you the output.

 

speedtest_flow

The main function node processes the data and sends it to a monitor so you can view the results in real time and also to a SQLite database.

Notice that when the node is running the process id of the system command is shown in the node status.

The debug nodes shows the standard output which contains our data and the result code which is 0 indicating success.

speedtest-debug

The results are displayed asĀ  a graph using the chart node.

peedtest-results-graph

The above graph shows the download speed dropping off a cliff and was taken from my Internet monitor during a recent Internet connection problem.

Node-Red Flow Download

download

Flow Video

The following video is a general video covering running external commands from node-red. The speed-test flow is at the end of the video.

Resources

Related Tutorials

 

Please Let me Know if you found it Useful
[Total: 6 Average: 3.8]

4 comments

  1. Dear Steve.

    I tried your program and on the debug node I can see the upload and download speeds. But it’s not plotting on the graf. Could help me, please. I am new to Node-Red and I like the program you built.

    Please help!

    Regards
    Subas

    1. Hi
      Check the configuration of the chart node. Do you get any error messages. If it is still a problem then use the ask steve page to contact me and I’ll send you another copy of the flow.
      rgds
      Steve

    1. Hi
      Sorry for the delay.I did a few videos for storing and reading data from sql and the flows are available to download in the video description. The flows contain simple inject nodes to create the tables. Here is a link to the first video
      Node-red Storing IOT data In a SQL Database
      https://youtu.be/d8eeNROMTv0

      Here is the flow used in the video
      http://www.steves-internet-guide.com/download/store-iot-data-in-sqlite-database/

      Here are links to the other videos
      Reading IOT Data From a SQL Database with Node-Red
      https://youtu.be/pQvbvuo11Yk
      ———
      Node-Red Storing IOT data In a SQL Database-Part 2
      https://youtu.be/fwF5xijNIWI

      Steve

Leave a Reply

Your email address will not be published. Required fields are marked *