speedtestlogger

module
v0.0.0-...-0ac7fff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: BSD-3-Clause

README

speedtestlogger

The app logs your home internet speeds. It is designed for MacOS.

Prerequisites

You must have the Speedtest cli by Ookla. Go here for instructions on how to install.

Architecture

This app actually contains 3 programs:

  • stlinit: You run this once during setup to initialize the sqlite file that will hold the internet speeds.
  • stllog: This program uses the CSV file from the Speedtest cli by Ookla to log the current internet speed in the sqlite file created by stlinit. Typically a cron job runs this program along with the Speedtest cli by Ookla once every hour.
  • stlview This program is the web server that serves the pages showing historical internet speeds.

Setup

  1. Clone this repository to ~/go/src/github.com/keep94/speedtestlogger.
  2. Compile the three programs from the previous section by running go install ... The 3 compiled executables can be found in ~/go/bin.
  3. Create the ~/stl directory to store the internet speeds.
  4. Run ~/go/bin/stlinit -db ~/stl/stl.db to create the sqlite3 file.
  5. Create the bash script to record the current internet speed and store in ~/go/bin/speedtest.sh
#!/bin/zsh

if /opt/homebrew/bin/speedtest -f csv &> stl_out.csv; then
    /Users/youruserid/go/bin/stllog -db stl.db -csv stl_out.csv
else
    /Users/youruserid/go/bin/stllog -db stl.db
fi

This tells the Speedtest cli to log the internet speeds to a csv file called stl_out.csv. If successful it runs the stllog program with that csv file. If unsuccessful, it runs stllog without a csv file, which causes stllog to record 0 upload speed and 0 download speed. The current working directory of this script will be ~/stl

  1. Create the plist file to run speedtest.sh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>yourlastname.speedtest</string>

        <key>UserName</key>
        <string>youruserid</string>

        <key>ProgramArguments</key>
        <array>
          <string>/Users/youruserid/go/bin/speedtest.sh</string>
        </array>

        <key>StartCalendarInterval</key>
        <array>
            <dict>
                <key>Minute</key>
                <integer>(choose an int between 0 and 59 inclusive)</integer>
            </dict>
        </array>

        <key>WorkingDirectory</key>
        <string>/Users/youruserid/stl</string>

        <key>StandardErrorPath</key>
        <string>/Users/youruserid/logs/speedtest/stderr.log</string>

        <key>StandardOutPath</key>
        <string>/Users/youruserid/logs/speedtest/stdout.log</string>

</dict>
</plist>

Store in /Library/LaunchDaemons in a file called yourlastname.speedtest.plist

  1. Create the plist file for stlview
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>yourlastname.stlview</string>

        <key>KeepAlive</key>
        <true/>

        <key>UserName</key>
        <string>youruserid</string>

        <key>ProgramArguments</key>
        <array>
          <string>/Users/youruserid/go/bin/stlview</string>
          <string>-db</string>
          <string>/Users/youruserid/stl/stl.db</string>
          <string>-http</string>
          <string>:9792</string>
        </array>

        <key>WorkingDirectory</key>
        <string>/Users/youruserid/stl</string>

        <key>StandardErrorPath</key>
        <string>/Users/youruserid/logs/stlview/stderr.log</string>

        <key>StandardOutPath</key>
        <string>/Users/youruserid/logs/stlview/stdout.log</string>

</dict>
</plist>

Using the Viewer

You can see the download speeds by going to http://localhost:9792. You can change this by entering a different port number besides 9792 in the plist file.

The home page shows you the download speeds for the current day. Use the breadcrumbs below the title to navigate the days, months, and years. Click on the "date range" breadcrumb to get statistics for an arbitrary date range.

Directories

Path Synopsis
cmd
stlinit command
stllog command
stlview command
stlview/common
Package common contains common routines for the stlview pages.
Package common contains common routines for the stlview pages.
stl
Package stl provides the data structures for the speedtestlogger app
Package stl provides the data structures for the speedtestlogger app
aggregators
Package aggregators aggregates values.
Package aggregators aggregates values.
dates
Package dates contains routines for converting between dates and timestamps.
Package dates contains routines for converting between dates and timestamps.
format
Package format provides formatting routines for speedtestlogger app.
Package format provides formatting routines for speedtestlogger app.
stldb
Package stldb handles storing instances in the speedtestlogger app to persistent storage.
Package stldb handles storing instances in the speedtestlogger app to persistent storage.
stldb/fixture
Package fixture provides test suites to test implementations of the datastore interfaces in the stldb package.
Package fixture provides test suites to test implementations of the datastore interfaces in the stldb package.
stldb/for_sqlite
Package for_sqlite provides a sqlite implementation of interfaces in the stldb package.
Package for_sqlite provides a sqlite implementation of interfaces in the stldb package.
stldb/sqlite_setup
Package sqlite_setup sets up a sqlite database for the speedtestlogger app
Package sqlite_setup sets up a sqlite database for the speedtestlogger app

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL