Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better approach in reading speedtest results here #9

Open
Bedasek opened this issue Jun 14, 2023 · 0 comments
Open

Better approach in reading speedtest results here #9

Bedasek opened this issue Jun 14, 2023 · 0 comments

Comments

@Bedasek
Copy link

Bedasek commented Jun 14, 2023

speedtest/Dockerfile:

Consider updating this line from:
RUN echo "${SPEEDTEST_CRON_SCHEDULE} root /usr/bin/speedtest --accept-license --accept-gdpr -s ${SPEEDTEST_SERVER} -f json > \$(mktemp -u -p /var/log/speedtest XXXXXX).json" > /etc/cron.d/speedtest
...to:
RUN echo "${SPEEDTEST_CRON_SCHEDULE} root /usr/bin/speedtest --accept-license --accept-gdpr -s ${SPEEDTEST_SERVER} -f json > /var/log/speedtest/results.json" > /etc/cron.d/speedtest

There is really no need to dump the results into unique json file every time. From long-term perspective and in conjuction with the speedtest being run every 1 minute, you will end up having 1440 files daily, 525k files in one year !!!!! That's crazy overkill and waste of resources.

Especially since telegraf agent is set to read all the files every 10s hence it reads THE SAME DATA of all thousands and thousand of files 6 times every one minute !!!!
Surely you can update telegraf agent interval to "1m" but that won't fix the inefficient usage of filesystem due to gazillion of files created by the speedtest and then being read by telegraf.

In the end, here below is the best of the best approaches.....
By doing this, telegraf agent executes the speedtest binary which dumps the json into stdout and telegraf reads and processed stdout and writes into influxdb.
Another advantage is also that you end up having just single container with both telegraf and speedtest in one nice package :)

[[inputs.exec]]
commands = ["/usr/bin/speedtest -f json-pretty"]
name_override = "Speedtest"
timeout = "1m"
interval = "5m"
data_format = "json"
json_string_fields = [ "interface_externalIp",
                       "server_name",
                       "server_location",
                       "server_host",
                       "server_ip",
                       "result_url" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant