Assorted shell and Python scripts
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5LOG_DIR="${HOME}/speedtest-logs"
6DAY="$(date '+%Y-%m-%d')"
7
8if [ ! -d "${LOG_DIR}" ]; then
9 mkdir -p "${LOG_DIR}"
10fi
11
12print_speed() {
13 _time=$(date '+%H:%M:%S')
14 _speedtest=$(speedtest++ --output text | tail -n 2)
15 _dl_speed=$(echo "$_speedtest" | head -n 1 | awk -F= '{print $2}')
16 _ul_speed=$(echo "$_speedtest" | tail -n 1 | awk -F= '{print $2}')
17 echo "${_time} [D: ${_dl_speed} MB/s] [U: ${_ul_speed} MB/s]"
18}
19
20print_speed >>"${LOG_DIR}/${DAY}.log"
21
22# vim: sw=4 ts=4 sts=4 ai et ft=bash