oitc/speedtest2mqtt

By oitc

Updated 9 days ago

A small docker image to combine the speedtest-cli together with the mosquitto_pub client.

Image
Networking
Developer tools
Monitoring & observability
0

1.4K

oitc/speedtest2mqtt repository overview

Quick reference

Maintained by: Michael Oberdorf IT-Consulting

Source code: GitHub

Container image: DockerHub

Summary

The container image is based on Alpine Linux and combines the speedtest-cli and the mosquitto-client to trigger a simple internet speedtest and publish the json formatted output to a MQTT server topic.

Prerequisites to run the docker container

You need an MQTT server to send the data to it.

Configuration

Container configuration

The container grab the configuration via environment variables.

Environment variable nameDescriptionRequiredDefault value
MQTT_SERVERThe MQTT server hostname or IP addressOPTIONALlocalhost
MQTT_PORTThe TCP port of the MQTT serverOPTIONAL1883
MQTT_TLS_enabledShould SSL communication be enabled (true) or not (false)OPTIONALfalse
MQTT_CACERT_FILEIf TLS is enabled, the path to the CA certificate file to validate the MQTT server certificateOPTIONAL
MQTT_TLS_no_hostname_validationIf TLS is enabled, skip the hostname validation of the TLS certificateOPTIONALfalse
MQTT_USERThe MQTT username for MQTT authenticationOPTIONAL
MQTT_PASSWORD_FILEThe filepath where the MQTT password is stored for MQTT authenticationOPTIONAL
MQTT_TOPICThe MQTT topic to send the speedtest results toMANDATORY
MQTT_RETAINSet the retain flag when publishing the speedtest result to MQTT topicOPTIONALfalse
FREQUENCETime in seconds between speedtests. If nothing is given, the container stops after 1 speedtestOPTIONAL
CLI Options

When starting the service, it is possible to add additional CLI options to the speedtest-cli command execution. By default, every execution will add the option --json.

So, every command you give to the container run, will be added to speedtest-cli --json.

Docker compose configuration

services:
  speedtest2mqtt:
    container_name: speedtest2mqtt
    restart: "no"
    read_only: true
    user: 2536:2536
    image: oitc/speedtest2mqtt:latest
    environment:
      MQTT_SERVER: test.mosquitto.org
      MQTT_PORT: 1883
      MQTT_TOPIC: de/oberdorf-itc/speedtest2mqtt/results
      FREQUENCE: 300
    secrets:
      - speedtest2mqtt_mqtt_password
    tmpfs:
      - /tmp

secrets:
  speedtest2mqtt_mqtt_password:
    file: /srv/docker/speedtest2mqtt/secrets/mqtt_password
Example with speedtest-cli command line options
services:
  speedtest2mqtt:
    container_name: speedtest2mqtt
    restart: "no"
    read_only: true
    user: 2536:2536
    image: oitc/speedtest2mqtt:latest
    command: ["--server", "15667"]
    environment:
      MQTT_SERVER: test.mosquitto.org
      MQTT_PORT: 1883
      MQTT_TOPIC: de/oberdorf-itc/speedtest2mqtt/results
      FREQUENCE: 300
    secrets:
      - speedtest2mqtt_mqtt_password
    tmpfs:
      - /tmp

secrets:
  speedtest2mqtt_mqtt_password:
    file: /srv/docker/speedtest2mqtt/secrets/mqtt_password

Donate

I would appreciate a small donation to support the further development of my open source projects.

Donate with PayPal

License

Copyright (c) 2023-2026 Michael Oberdorf IT-Consulting

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tag summary

Content type

Image

Digest

sha256:f740ca098

Size

20 MB

Last updated

9 days ago

docker pull oitc/speedtest2mqtt