Skip to content

Commit

Permalink
Document tools better
Browse files Browse the repository at this point in the history
  • Loading branch information
guenhter committed Jun 8, 2024
1 parent 0994d8c commit 5619334
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This scripts setup a Raspberry PI to
* periodically (default 10 minutes) make an internet speedtest and store the results locally as json
* act as an iPerf3 Server to be used for testing the LAN speed (the setup is interactive: Select "Yes" when iperf ask if it should install a daemon)


## Scripts

* `setup-speedtest-tools.sh`: Setup all the necessary speedtest tools including the cron job

## iperf3

To trigger iperf3 on client side, run this command:
Expand Down
7 changes: 7 additions & 0 deletions results-to-csv.sh → scripts/results-to-csv.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
## Usage: results-to-csv.sh [SPEEDTEST_RESULTS_FOLDER]
##
## This script converts all collected speedtest result json's into
## one csv containing selected fields from each result.
## The all_results.csv is stored one hierarchy above the
## SPEEDTEST_RESULTS_FOLDER folder
##

RESULTS_ROOT=${1:-/opt/speedtest-results}

Expand Down
18 changes: 18 additions & 0 deletions scripts/speedtest-periodic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
## Usage: speedtest-periodic.sh [SPEEDTEST_RESULTS_FOLDER]
##
## This script runs the actual speedtest and redirect its output
## into a json. The filename of the resulting json is the current
## time at minute precision.
## In case error occurs, the error is just written to the resulting
## json, even if it is not valid json syntax.
##

RESULTS_ROOT=${1:-/opt/speedtest-results}

mkdir -p "$RESULTS_ROOT"

OUT_FILE="$RESULTS_ROOT/$(date +\%Y-\%m-\%dT\%H:\%M).json"
ERROR_LOG="$RESULTS_ROOT/errors"

speedtest -f json --accept-license --accept-gdpr 1>"$OUT_FILE" 2>&1
2 changes: 1 addition & 1 deletion setup-speedtest-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function install_periodic_speedtest() {
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash
apt-get -y install speedtest

cp "$SCRIPT_DIR/speedtest-periodic.sh" /opt/speedtest-periodic.sh
cp "$SCRIPT_DIR/scripts/*.sh" /opt/

sudo tee /etc/cron.d/speedtest <<'EOF'
*/10 * * * * root /opt/speedtest-periodic.sh
Expand Down
10 changes: 0 additions & 10 deletions speedtest-periodic.sh

This file was deleted.

4 changes: 2 additions & 2 deletions test/test-results-to-csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function test_resulting_csv() {


# Execute script under test
bash "$SCRIPT_DIR"/../results-to-csv.sh "$TEMP_DIR/jsons"
bash "$SCRIPT_DIR"/../scripts/results-to-csv.sh "$TEMP_DIR/jsons"


# Assertions
Expand Down Expand Up @@ -46,7 +46,7 @@ function test_resulting_csv_if_error_file_is_there() {


# Execute script under test
bash "$SCRIPT_DIR"/../results-to-csv.sh "$TEMP_DIR/jsons"
bash "$SCRIPT_DIR"/../scripts/results-to-csv.sh "$TEMP_DIR/jsons"


# Assertions
Expand Down

0 comments on commit 5619334

Please sign in to comment.