[NODE-RED] SpeedTest++ via Docker

Hello,

Voici, un flux qui permet de lancer un SpeedTest++ (version évoluer de SpeedTest classic) via Node-RED.

Il est nécessaire d’avoir accès en SSH à un Host avec le moteur Docker d’installer afin de boot le conteneur qui va s’occuper de faire le SpeedTest.

[
{
    "id": "1f68a633.64bf4a",
    "type": "group",
    "z": "30b9d5a2.2b5b9a",
    "name": "SpeedTest++",
    "style": {
        "stroke": "#000000",
        "fill": "#7fb7df",
        "label": true,
        "color": "#000000"
    },
    "nodes": [
        "4f2ff236.7a08fc",
        "625e2114.caf74",
        "a92c9709.117878",
        "9757dab8.b2ba88",
        "f511863.4544778",
        "dc435888.af6948",
        "4f696161.42ed5",
        "169f1b0f.688ee5",
        "81d02db0.cb261",
        "fcd09ad7.42ff38",
        "5b79304d.97f9f",
        "f415752.c21ab88",
        "34b7b0c1.eb43d",
        "329d0613.a55bda",
        "a859b9c0.85a778"
    ],
    "x": 34,
    "y": 1059,
    "w": 1352,
    "h": 362
},
{
    "id": "4f2ff236.7a08fc",
    "type": "inject",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "props": [
        {
            "p": "payload"
        },
        {
            "p": "topic",
            "vt": "str"
        }
    ],
    "repeat": "3600",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "",
    "payloadType": "date",
    "x": 150,
    "y": 1260,
    "wires": [
        [
            "34b7b0c1.eb43d"
        ]
    ]
},
{
    "id": "625e2114.caf74",
    "type": "bigssh",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "commandLine": "",
    "commandArgs": "",
    "minError": 1,
    "minWarning": 1,
    "noStdin": false,
    "format": "utf8",
    "payloadIsArg": true,
    "myssh": "93f53b93.708328",
    "x": 590,
    "y": 1260,
    "wires": [
        [
            "a92c9709.117878",
            "a859b9c0.85a778"
        ],
        [
            "a859b9c0.85a778"
        ],
        [
            "a859b9c0.85a778"
        ]
    ]
},
{
    "id": "a92c9709.117878",
    "type": "json",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "property": "payload",
    "action": "",
    "pretty": true,
    "x": 790,
    "y": 1260,
    "wires": [
        [
            "9757dab8.b2ba88",
            "f511863.4544778",
            "f415752.c21ab88"
        ]
    ]
},
{
    "id": "9757dab8.b2ba88",
    "type": "unit-converter",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "category": "digital",
    "inputUnit": "b",
    "outputUnit": "Mb",
    "inputField": "payload.download",
    "outputField": "payload",
    "inputFieldType": "msg",
    "outputFieldType": "msg",
    "roundOutputField": true,
    "outputFieldDecimals": 2,
    "name": "Download",
    "x": 990,
    "y": 1170,
    "wires": [
        [
            "dc435888.af6948",
            "81d02db0.cb261",
            "329d0613.a55bda"
        ]
    ]
},
{
    "id": "f511863.4544778",
    "type": "unit-converter",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "category": "digital",
    "inputUnit": "b",
    "outputUnit": "Mb",
    "inputField": "payload.upload",
    "outputField": "payload",
    "inputFieldType": "msg",
    "outputFieldType": "msg",
    "roundOutputField": true,
    "outputFieldDecimals": 2,
    "name": "Upload",
    "x": 990,
    "y": 1260,
    "wires": [
        [
            "4f696161.42ed5",
            "fcd09ad7.42ff38",
            "329d0613.a55bda"
        ]
    ]
},
{
    "id": "dc435888.af6948",
    "type": "mqtt out",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "topic": "nodered/speedtest/download",
    "qos": "0",
    "retain": "true",
    "broker": "5a120b36.df9674",
    "x": 1240,
    "y": 1190,
    "wires": []
},
{
    "id": "4f696161.42ed5",
    "type": "mqtt out",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "topic": "nodered/speedtest/upload",
    "qos": "0",
    "retain": "true",
    "broker": "5a120b36.df9674",
    "x": 1230,
    "y": 1280,
    "wires": []
},
{
    "id": "169f1b0f.688ee5",
    "type": "mqtt out",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "topic": "nodered/speedtest/latency",
    "qos": "0",
    "retain": "true",
    "broker": "5a120b36.df9674",
    "x": 1240,
    "y": 1380,
    "wires": []
},
{
    "id": "81d02db0.cb261",
    "type": "influxdb out",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "influxdb": "57d9cd06.0e4dc4",
    "name": "",
    "measurement": "speedtest_download",
    "precision": "",
    "retentionPolicy": "",
    "x": 1240,
    "y": 1150,
    "wires": []
},
{
    "id": "fcd09ad7.42ff38",
    "type": "influxdb out",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "influxdb": "57d9cd06.0e4dc4",
    "name": "",
    "measurement": "speedtest_upload",
    "precision": "",
    "retentionPolicy": "",
    "x": 1230,
    "y": 1240,
    "wires": []
},
{
    "id": "5b79304d.97f9f",
    "type": "influxdb out",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "influxdb": "57d9cd06.0e4dc4",
    "name": "",
    "measurement": "speedtest_ping",
    "precision": "",
    "retentionPolicy": "",
    "x": 1220,
    "y": 1340,
    "wires": []
},
{
    "id": "f415752.c21ab88",
    "type": "function",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "Convert2Int",
    "func": "msg.payload = parseInt(msg.payload.ping);\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "x": 1000,
    "y": 1360,
    "wires": [
        [
            "5b79304d.97f9f",
            "169f1b0f.688ee5",
            "329d0613.a55bda"
        ]
    ]
},
{
    "id": "34b7b0c1.eb43d",
    "type": "function",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "Set Server + Command",
    "func": "var speedtest_server = \"speedtest101.proximus.be:8080\";\nvar cmd = \"docker run --rm -t m4dm4rtig4n/speedtest:latest --test-server \"+speedtest_server+\" --output json\";\n\nmsg.payload = cmd;\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "x": 370,
    "y": 1260,
    "wires": [
        [
            "625e2114.caf74"
        ]
    ]
},
{
    "id": "329d0613.a55bda",
    "type": "debug",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "Débit",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 1170,
    "y": 1100,
    "wires": []
},
{
    "id": "a859b9c0.85a778",
    "type": "debug",
    "z": "30b9d5a2.2b5b9a",
    "g": "1f68a633.64bf4a",
    "name": "",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "false",
    "statusVal": "",
    "statusType": "auto",
    "x": 790,
    "y": 1170,
    "wires": []
},
{
    "id": "93f53b93.708328",
    "type": "SSH_Credentials",
    "host": "MON.REMOTE.SERVEUR",
    "port": "22",
    "userlabel": "MON.REMOTE.SERVEUR"
},
{
    "id": "5a120b36.df9674",
    "type": "mqtt-broker",
    "name": "MQTT",
    "broker": "MON.SERVEUR.MQTT",
    "port": "1883",
    "clientid": "node-red",
    "usetls": false,
    "compatmode": false,
    "keepalive": "60",
    "cleansession": false,
    "birthTopic": "",
    "birthQos": "0",
    "birthRetain": "true",
    "birthPayload": "",
    "closeTopic": "",
    "closeQos": "0",
    "closeRetain": "true",
    "closePayload": "",
    "willTopic": "",
    "willQos": "0",
    "willRetain": "true",
    "willPayload": ""
},
{
    "id": "57d9cd06.0e4dc4",
    "type": "influxdb",
    "hostname": "MON.REMOTE.SERVEUR.INFLUXDB",
    "port": "8086",
    "protocol": "http",
    "database": "MA.BDD",
    "name": "HASS",
    "usetls": false,
    "tls": "2923591e.104216"
},
{
    "id": "2923591e.104216",
    "type": "tls-config",
    "name": "",
    "cert": "",
    "key": "",
    "ca": "",
    "certname": "",
    "keyname": "",
    "caname": "",
    "servername": "",
    "verifyservercert": false
}
]

Le tout est balancer dans MQTT et InfluxDB :slight_smile:

Vous pouvez trouvez la liste des serveurs SpeedTest ici (prendre le champ Host) :
https://c.speedtest.net/speedtest-servers-static.php

Excellent. Merci Beaucoup