HenrikBengtsson / speedtest-cli-extras

:signal_strength: Tools to enhance the speedtest-cli network tools
120 stars 32 forks source link

Updates to allow data exports #17

Closed csawall closed 8 years ago

csawall commented 8 years ago

I made some updates so that someone could easily save their data results to ThingSpeak, a Slack channel, a Google Sheet, or to a IFTTT channel (another way to access a Google Sheet). I thought it might be more beneficial long-term and easier to store data to perform analytics against, or graph out. I also changed how the script writes to a local CSV file. All comments updated as well.

I realize you may not want all of this, but it has helped me. Thank you for the consideration and review.

HenrikBengtsson commented 8 years ago

Thanks for these suggestions. I've updated the help to clarify what the defaults are (as you propose here).

About adding options to send to different third-party services:
First, authentication keys or other user specific variables must not be part of the speedtest-csv script. Instead such values should / could be specified via environment variables set in, say, ~/.bashrc. More importantly, instead of adding code for sending the results to these different services, wouldn't it be better to pass the output of speedtest-csv to them using for instance a Bash function. If you add the following to your ~/.bashrc,

function ifttt { 
    event=MyEventName
    key=MyKey
    data="{\"value1\":\"$1\",\"value2\":\"$2\",\"value3\":\"$3\"}"
    curl --silent --request POST --header "Content-Type: application/json" --data "${data}" https://maker.ifttt.com/trigger/${event}/with/key/${key}
}

then you should be able to do

ifttt $(speedtest-csv --sep '\t' --header-units | cut -d$'\t' -f 7-9)

Note that --header-units, which drops units from values, will be part of the next release, which you can find already now in https://github.com/HenrikBengtsson/speedtest-cli-extras/tree/develop.

HenrikBengtsson commented 8 years ago

FYI, speedtest-csv 1.3.0 has now been released, which now includes the above --header-units.

csawall commented 8 years ago

Thanks for reviewing and commenting. You bring up great points! I like the added option of --header-units now. I'll update the version I'm using to 1.3 and leverage your recommendation. Have a great weekend!

HenrikBengtsson commented 8 years ago

Cheers :)