Updated: November 5, 2019

Monitor Internet Speeds with Speedtest-cli and Node-Red

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.

Running Speedtest in Node-red

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

Here is a screenshot of the node configuration; notice how the command line options are passed to the command

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.

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.

speedtest_flow

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.

Flow Download

Flow Video

Coming Soon

Resources

Related Tutorials

Internet speeds explained

Please Let me Know if you found it Useful
[Total: 2 Average: 3.5]

Leave a Reply

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

* Copy This Password *

* Type Or Paste Password Here *