Closed dirkduplooy closed 3 years ago
You could do that with the following steps.
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".
@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?
@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.
Will it be possible to plot the latency as well during the test as a 3rd graph?