pedrocesarti / internet-speedtest-docker

Internet testing running on Docker Compose.
116 stars 40 forks source link

Latency #18

Closed dirkduplooy closed 3 years ago

dirkduplooy commented 5 years ago

Will it be possible to plot the latency as well during the test as a 3rd graph?

forcerk commented 4 years ago

You could do that with the following steps.

  1. Edit the file app/speedweb/init_test_connection.sh at the speedweb container. Add the following two lines.
    LATENCY=$(cat $FILE | grep "Hosted" | awk -F ":" '{print $2}' | awk -F " " '{print $1}')
    curl -i -XPOST 'http://db:8086/write?db=speedtest' --data-binary "latency,host=local value=$LATENCY"

    So the final script look like this.

    
    #!/bin/bash
    FILE="/app/speedtest/test_connection.log"

while true do TIMESTAMP=$(date '+%s')

    /app/speedtest/speedtest_cli.py > $FILE

    DOWNLOAD=$(cat $FILE | grep "Download:" | awk -F " " '{print $2}')
    UPLOAD=$(cat $FILE | grep "Upload:" | awk -F " " '{print $2}')
    LATENCY=$(cat $FILE | grep "Hosted" | awk -F ":" '{print $2}' | awk -F " " '{print $1}')
    echo "Download: $DOWNLOAD Upload: $UPLOAD Latency: $LATENCY   $TIMESTAMP"
    curl -i -XPOST 'http://db:8086/write?db=speedtest' --data-binary "download,host=local value=$DOWNLOAD"
    curl -i -XPOST 'http://db:8086/write?db=speedtest' --data-binary "upload,host=local value=$UPLOAD"
    curl -i -XPOST 'http://db:8086/write?db=speedtest' --data-binary "latency,host=local value=$LATENCY"
    sleep $TEST_INTERVAL

done



2. Edit the Grafana dashboard to show the new measurement called "latency".
cjoha commented 4 years ago

@forcerk - I've made this change locally, then running "docker-compose up -d" to pull the new init_test_connection.sh configuration into the running configuration. I then logon to Grafana but I cannot see the new latency metric (creating a new graph, or suplicating the download one and then trying to edit it). Am I missing something else?

forcerk commented 4 years ago

@cjoha - I don't see that you are missing something. I do have a fork that you can check if it is working for you. You can find it here: https://github.com/forcerk/internet-speedtest-docker/blob/master/speedtest/scripts/init_test_connection.sh I hope this is helping you out.