From 1704cab223ce9087e4ba483f31fd98cd768d8f09 Mon Sep 17 00:00:00 2001 From: Lucas Falk Beier Date: Sun, 7 Feb 2021 17:14:22 +0100 Subject: [PATCH] Removing unnecessary option and fixing conversion First of all, thanks for this excellent template. I've applied two small fixes. The first one is removing the unnecessary `-u Mbps` option in the command. As per the docs, this option is only applicable for the `human-readable` output. The second one is a fix in the download and upload conversion. The output bandwidth for both download and upload is returned in bytes. In order to have it in megabit per second, which matches the suffix `Mb/s` used in the template, we need to divide it by `125000` instead of `100000`. --- speedtest/speedtest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/speedtest/speedtest.yml b/speedtest/speedtest.yml index 065b41f3..acb5ce04 100644 --- a/speedtest/speedtest.yml +++ b/speedtest/speedtest.yml @@ -202,7 +202,7 @@ spec: |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "exec_speedtest") |> filter(fn: (r) => r["_field"] == "download_bandwidth") - |> map(fn: (r) => ({ r with _value: r._value / 100000.0 })) + |> map(fn: (r) => ({ r with _value: r._value / 125000.0 })) |> yield(name: "last") shade: true suffix: ' Mb/s' @@ -236,7 +236,7 @@ spec: |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "exec_speedtest") |> filter(fn: (r) => r["_field"] == "upload_bandwidth") - |> map(fn: (r) => ({ r with _value: r._value / 100000.0 })) + |> map(fn: (r) => ({ r with _value: r._value / 125000.0 })) |> yield(name: "last") shade: true suffix: ' Mb/s' @@ -280,7 +280,7 @@ spec: [[inputs.exec]] ## Commands array - commands = ["speedtest --format=json-pretty -u Mbps"] + commands = ["speedtest --format=json-pretty"] ## Timeout for each command to complete. timeout = "90s" @@ -292,4 +292,4 @@ spec: ## Each data format has its own unique set of configuration options, read ## more about them here: ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "json" \ No newline at end of file + data_format = "json"