Email yourself an internet speed test report
Run Ookla's speed test on a Linux box and email the result, for example to keep a record of your ISP's performance.
Install the Ookla CLI
Install it from Ookla's package repository, rather than piping a web script into sudo bash:
# Download the repo setup script, read it, then run it
curl -fsSLo /tmp/ookla.sh https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh
less /tmp/ookla.sh && sudo bash /tmp/ookla.sh
sudo dnf install speedtest
To check whether a package is installed, use rpm -q speedtest. rpm -qa speedtest always returns success, even when the package is missing.
Run and send
#!/bin/bash
set -euo pipefail
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
speedtest --accept-license --accept-gdpr > "$tmp/speedtest.txt"
enscript -q -p - "$tmp/speedtest.txt" | ps2pdf - "$tmp/speedtest.pdf"
mutt -s "Speed test $(hostname -s) $(date +%F)" -a "$tmp/speedtest.pdf" -- you@example.com < "$tmp/speedtest.txt"
Points to note:
- Run
muttin the foreground. If you background it with&and then delete the attachment, the email can go out without it. - Use
mktemprather than fixed names in/tmp.
Requirements
speedtest, enscript, ghostscript (ps2pdf), mutt and a working mail relay.
Schedule it (optional)
0 7 * * * root /usr/local/bin/speedtest-report.sh