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
* 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
* 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.
influx_data = [
{
"measurement": "ping",
"time": data["timestamp"],
"fields": {
"jitter": data["ping"]["jitter"],
"latency": data["ping"]["latency"],
},
},
{
"measurement": "packetLoss",
"time": data["timestamp"],
@ -111,9 +103,9 @@ def format_for_influx(data):
"measurement": "speeds",
"time": data["timestamp"],
"fields": {
"jitter": data["ping"]["jitter"],
"latency": data["ping"]["latency"],
"packetLoss": pkt_loss(data),
"ping_jitter": data["ping"]["jitter"],
"ping_latency": data["ping"]["latency"],
"packet_loss": pkt_loss(data),
"bandwidth_down": data["download"]["bandwidth"],
"bytes_down": data["download"]["bytes"],
"elapsed_down": data["download"]["elapsed"],
@ -162,9 +154,9 @@ def speedtest():
+ str(data_json["ping"]["latency"])
+ " ms - download: "
+ str(data_json["download"]["bandwidth"])
+ " Mb/s - upload: "
+ " b/s - upload: "
+ str(data_json["upload"]["bandwidth"])
+ " Mb/s - isp: "
+ " b/s - isp: "
+ data_json["isp"]
+ " - ext. IP: "
+ data_json["interface"]["externalIp"]