A robust, headless Raspberry Pi solution that automatically monitors internet speed every 15 minutes with comprehensive failure logging and syncs data to a local SMB network share.
- π Automated Testing: Speed tests every 15 minutes via cron
- π Rich Data Logging: Download/upload speeds, ping, server info, and failure tracking
- π Comprehensive Error Logging: Detailed failure analysis and categorization
- π SMB Network Sync: Automatic sync to network share for remote access
- π Data Visualization: Clean display of successes, failures, and statistics
- βοΈ Headless Operation: No GUI required, perfect for Raspberry Pi
- π No Cloud Dependencies: All data stays on your local network
- π Organized Storage: Dedicated speedtest directory structure
- π οΈ Easy Setup: One-command installation with rerunnable setup script
# Clone the repository
git clone https://github.com/jamescummins/speedtest_monitor.git
cd speedtest_monitor
# Run the automated setup (rerunnable)
chmod +x setup.sh
./setup.shThe setup script automatically:
- β Installs system dependencies (python3-venv, cifs-utils)
- β Creates isolated Python virtual environment
- β Installs speedtest-cli package
- β Sets up systemd service
- β Configures cron job for 15-minute intervals
- β Creates data directories
Option A: Use included mount script
# Edit mount.sh with your SMB details
nano mount.sh
# Run the mount script
./mount.shOption B: Manual mount
sudo mkdir -p /media/test
sudo mount -t cifs //your-server/share /media/test -o username=user,password=pass,uid=$(id -u),gid=$(id -g)Option C: Persistent mount (recommended)
sudo nano /etc/fstab
# Add: //server/share /media/test cifs username=user,password=pass,uid=1000,gid=1000 0 0
sudo mount -a# Test SMB setup and connectivity
python test_setup.py
# Run manual speed test
python speedtest_monitor.py
# View results with failure analysis
python view_data.pyYour speed test data includes comprehensive failure tracking:
JSON Columns:
timestamp: ISO format date/timedownload_mbps: Download speed in Mbpsupload_mbps: Upload speed in Mbpsping_ms: Ping latency in millisecondsserver_name: Speed test server nameserver_country: Server countryserver_sponsor: Server providerstatus: SUCCESS or FAILEDerror_type: Type of error if failederror_details: Detailed error information
# Comprehensive data view with failure analysis
python view_data.py
# Monitor live logs
tail -f speedtest_data/speedtest.log
# Check cron execution
tail -f speedtest_data/cron.logThe system tracks and categorizes failures:
- π§ ConfigRetrievalError: Network/ISP blocking issues
- π NoMatchedServers: Regional restrictions
- π‘ SpeedtestHTTPError: Server/rate limiting issues
- π― BestServerError: Server selection failures
- β¬οΈ DownloadTestError: Download test failures
- β¬οΈ UploadTestError: Upload test failures
- πΎ JSONSaveError: Local file save issues
- π SMBSyncFailed: Network share sync problems
Your data automatically syncs to /media/test/speedtest/:
- π
speed_history.csv- All test results with failure data - π
speedtest.log- Detailed application logs - π Access from any device on your network
- π Import CSV into Excel, Google Sheets, etc.
# View cron jobs
crontab -l
# Check if running automatically
tail speedtest_data/cron.log
# Manual speed test
python speedtest_monitor.py
# Test with debug output
DEBUG=1 python speedtest_monitor.py# Manual run via systemd
sudo systemctl start speedtest-monitor.service
# Check service status
sudo systemctl status speedtest-monitor.service
# View service logs
sudo journalctl -u speedtest-monitor.service# Check if mounted
mount | grep /media/test
# Test SMB access and permissions
python test_setup.py
# Remount if needed
sudo umount /media/test
sudo mount -a
# Check mount script
./mount.sh# Check cron job exists with correct paths
crontab -l
# Check cron service is running
sudo systemctl status cron
# Check for cron errors
grep CRON /var/log/syslog# Recreate virtual environment if needed
rm -rf ~/.venv/speedtest_monitor
./setup.sh
# Manual activation
source ~/.venv/speedtest_monitor/bin/activate# Test basic connectivity
ping google.com
# Test speedtest CLI directly
source ~/.venv/speedtest_monitor/bin/activate
speedtest-cli
# Check if servers are accessible
speedtest-cli --listspeedtest_monitor/
βββ speedtest_monitor.py # Main monitoring script with failure logging
βββ test_setup.py # SMB connectivity and permission testing
βββ view_data.py # Data viewer with failure analysis
βββ test_failure.py # Failure simulation for testing
βββ setup.sh # Automated setup script (rerunnable)
βββ mount.sh # SMB mounting helper script
βββ requirements.txt # Python dependencies
βββ README.md # This documentation
βββ speedtest_data/ # Local data storage
βββ speed_history.csv # Speed test results with failure data
βββ speedtest.log # Detailed application logs
βββ cron.log # Cron execution logs
- π Privacy: Your data never leaves your network
- π Reliability: No cloud outages or API rate limits
- π° Cost: No monthly cloud storage fees
- π§ Simplicity: No OAuth flows or API keys to manage
- πΆ Offline Access: View data even without internet
- π Network Integration: Works with existing SMB/NAS setup
# Edit cron job (currently every 15 minutes)
crontab -e
# Change */15 to */30 for 30 minutes, */5 for 5 minutes, etc.Extend speedtest_monitor.py to capture:
- Multiple server comparisons
- Network interface information
- System temperature monitoring
- Historical trend analysis
# Simple Flask dashboard example
from flask import Flask, render_template
import pandas as pd
app = Flask(__name__)
@app.route('/')
def dashboard():
df = pd.read_csv('speedtest_data/speed_history.csv')
return render_template('dashboard.html',
successful=df[df['status']=='SUCCESS'],
failed=df[df['status']=='FAILED'])- System Impact: Minimal CPU/RAM usage
- Storage Growth: ~50-100MB per year
- Bandwidth Usage: ~100MB/month for tests
- Power Consumption: ~$2/year on Raspberry Pi
- Reliability: 99%+ uptime with proper setup
# Enable detailed logging
DEBUG=1 python speedtest_monitor.py# Test failure logging system
python test_failure.py# Test SMB connectivity
python test_setup.py
# Mount SMB with custom options
./mount.shβ±οΈ Setup Time: ~5-10 minutes
π§ Maintenance: Near zero
π Data Access: Full network availability via SMB
π‘οΈ Reliability: Comprehensive error handling and logging