Remove ping duplication from data model

Simplified data model slightly by removing ping fields being sent both
as `ping` measures and as fields on the `speed` measure. Most things are
now only sent directly through the `speed` measure.
This commit is contained in:
Marty Oehme 2021-05-19 15:39:13 +02:00
parent 0d868c05fe
commit d614cbefe1
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 6 additions and 14 deletions

View file

@ -17,7 +17,7 @@ There are some added features to allow some additional details that Ookla provid
* Slightly different environment variables to set up InfluxDB connection * Slightly different environment variables to set up InfluxDB connection
* Speeds will be returned in bytes without transforming into MBit/s, just like the speedtest does * Speeds will be returned in bytes without transforming into MBit/s, just like the speedtest does
* The measure duplication of `speeds>bandwith_up/down` and `download>bandwith` and `upload>bandwith` has been removed, leaving only the `speeds` fields. * The measure duplication of `speeds>bandwith_up/down` and `download>bandwith` and `upload>bandwith` has been removed, leaving only the `speeds` fields. Same thing with `ping` and `speeds>latency/jitter` duplication.
* Setting a ping/speedtest interval of 0 will turn the respective test off * Setting a ping/speedtest interval of 0 will turn the respective test off
* By default only failed tests will be printed to stdout/stderr, this can be controlled through `SPEEDTEST_DEBUG` * By default only failed tests will be printed to stdout/stderr, this can be controlled through `SPEEDTEST_DEBUG`

18
main.py
View file

@ -94,14 +94,6 @@ def format_for_influx(data):
# There is additional data in the speedtest-cli output but it is likely not necessary to store. # There is additional data in the speedtest-cli output but it is likely not necessary to store.
influx_data = [ influx_data = [
{
"measurement": "ping",
"time": data["timestamp"],
"fields": {
"jitter": data["ping"]["jitter"],
"latency": data["ping"]["latency"],
},
},
{ {
"measurement": "packetLoss", "measurement": "packetLoss",
"time": data["timestamp"], "time": data["timestamp"],
@ -111,9 +103,9 @@ def format_for_influx(data):
"measurement": "speeds", "measurement": "speeds",
"time": data["timestamp"], "time": data["timestamp"],
"fields": { "fields": {
"jitter": data["ping"]["jitter"], "ping_jitter": data["ping"]["jitter"],
"latency": data["ping"]["latency"], "ping_latency": data["ping"]["latency"],
"packetLoss": pkt_loss(data), "packet_loss": pkt_loss(data),
"bandwidth_down": data["download"]["bandwidth"], "bandwidth_down": data["download"]["bandwidth"],
"bytes_down": data["download"]["bytes"], "bytes_down": data["download"]["bytes"],
"elapsed_down": data["download"]["elapsed"], "elapsed_down": data["download"]["elapsed"],
@ -162,9 +154,9 @@ def speedtest():
+ str(data_json["ping"]["latency"]) + str(data_json["ping"]["latency"])
+ " ms - download: " + " ms - download: "
+ str(data_json["download"]["bandwidth"]) + str(data_json["download"]["bandwidth"])
+ " Mb/s - upload: " + " b/s - upload: "
+ str(data_json["upload"]["bandwidth"]) + str(data_json["upload"]["bandwidth"])
+ " Mb/s - isp: " + " b/s - isp: "
+ data_json["isp"] + data_json["isp"]
+ " - ext. IP: " + " - ext. IP: "
+ data_json["interface"]["externalIp"] + data_json["interface"]["externalIp"]