summaryrefslogtreecommitdiff
path: root/log.sh
diff options
context:
space:
mode:
authorSteph Enders <steph@senders.io>2023-11-11 22:55:28 -0500
committerSteph Enders <steph@senders.io>2023-11-11 22:55:28 -0500
commita9ea07699e4f8c7b65d9ccb84d1ccc993f9e3cad (patch)
treee5ca8f2a2b444184bba32daf651668e64dde8049 /log.sh
Initial commit of simple functional speedtest log
This series of scripts simply calls speedtest-cli python module to basically log its data to a tsv file (expected log.tsv) This will basically allow then ./plot.sh to plot the file datapoints The idea is to set this up as a cron and then you can plot the data over time
Diffstat (limited to 'log.sh')
-rwxr-xr-xlog.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/log.sh b/log.sh
new file mode 100755
index 0000000..7357c76
--- /dev/null
+++ b/log.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+WORKING_DIR=$(dirname $0)
+python3 -m venv $WORKING_DIR/.venv
+source $WORKING_DIR/.venv/bin/activate
+python3 -m pip install -r $WORKING_DIR/requirements.txt
+
+if [[ $# -ne 1 ]]; then
+ echo "You must supply a target file"
+ exit 1
+fi
+
+OUTPUT=$1
+
+if [[ ! -f $OUTPUT ]]; then
+ speedtest-cli --csv-header | sed -E 's/,/\t/g' > $OUTPUT
+fi
+
+len=$(wc -l $OUTPUT | cut -d' ' -f1)
+if [[ $len -le 0 ]]; then
+ speedtest-cli --csv-header | sed -E 's/,/\t/g' > $OUTPUT
+fi
+
+speedtest-cli --csv-delimiter ' ' --csv >> $OUTPUT