A Python application for testing internet speed and visualizing results using MRTG (Multi Router Traffic Grapher) with Apache.
- β‘ Speed Testing: Test download speed, upload speed, and ping/latency
- π Data Logging: Save all test results to JSON for historical tracking
- π MRTG Graphing: Generate beautiful graphs using MRTG served via Apache
- π‘ Zabbix Integration: Export metrics to Zabbix for enterprise monitoring
- π€ Automated Testing: Cron job runs speed tests at configurable intervals
- π Automated Graphing: Cron job updates MRTG graphs at configurable intervals
- π Idempotent Setup: All setup scripts can be run multiple times safely
- π Web Access: View graphs from any device on your network via Apache
- Configuration
- Installation
- Setup Scripts
- Core Scripts
- Zabbix Integration
- Usage
- Project Structure
- Data Format
- Cron Jobs
- Troubleshooting
- Requirements
Before running setup, you need to configure your IP address and other settings:
cp vars.example vars# Apache IP address and port
APACHE_LISTEN_IP="YOUR_IP_ADDRESS"
APACHE_LISTEN_PORT="80"
# Speedtest cron interval (in minutes)
SPEEDTEST_INTERVAL="10"
# MRTG update interval (in minutes)
MRTG_UPDATE_INTERVAL="5"
β οΈ Important: Thevarsfile is ignored by git and contains your local configuration. Do not commit it to version control.
-
Install Python dependencies:
python3 -m pip install -r requirements.txt
-
Configure your settings (see Configuration section above)
-
Run the master setup script (requires root for Apache configuration):
sudo ./setup_all.sh
This will automatically:
- β Install MRTG and Apache (if not already installed)
- β Configure MRTG for speedtest graphing
- β Set up Apache to serve MRTG graphs on your configured IP address
- β Configure firewall to allow traffic
- β Create cron jobs for automated testing and graph updates
- β Initialize MRTG log files with initial data points
- β Set up Zabbix integration (if Zabbix agent is installed)
All setup scripts are idempotent - they can be run multiple times safely without causing issues.
What it does:
- π― Orchestrates the complete setup process
- π Calls all other setup scripts in the correct order
- π Displays a summary with your configured IP address and intervals
- β
Validates that the
varsfile exists and is properly configured
When to use:
- First-time setup
- Complete system reconfiguration
- After pulling updates from git
Usage:
sudo ./setup_all.shPost-setup:
- All components are configured and ready
- Apache is running and serving graphs
- Cron jobs are active and will run automatically
What it does:
- π₯ Installs MRTG package (if not already installed)
- π Installs Apache/HTTPD (if not already installed)
- π Creates MRTG directory structure (
mrtg/cfg/,mrtg/html/,mrtg/logs/,mrtg/work/) - βοΈ Generates MRTG configuration files for download, upload, and ping metrics
- π§ Configures Apache to listen on your specified IP address
- πͺ Sets up Apache VirtualHost for MRTG graphs
- π₯ Configures firewall (firewalld, ufw, or iptables) to allow HTTP traffic
- π Sets proper file permissions and SELinux contexts
- π Creates index.html landing page for easy navigation
- π« Disables default MRTG config that restricts access to localhost
- π Runs initial MRTG updates to create log files
When to use:
- Setting up MRTG and Apache for the first time
- Reconfiguring Apache IP address
- Fixing permission or SELinux issues
- After system updates that might have reset configurations
Usage:
sudo ./setup_mrtg.shPost-setup:
- MRTG is installed and configured
- Apache is running on your specified IP:port
- MRTG configuration files are in
mrtg/cfg/ - HTML directory is ready at
mrtg/html/ - Graphs are accessible via web browser
- Firewall allows incoming HTTP connections
What it does:
- π Creates a cron job to run speed tests automatically
- β±οΈ Uses interval from
varsfile (default: every 10 minutes) - π Adds cron job with unique tag for easy identification
- π Updates existing cron job if it already exists (idempotent)
- π Logs all speed test runs to
speedtest_cron.log
When to use:
- Setting up automated speed testing
- Changing the speed test interval
- After manual cron job deletion
- When speed tests aren't running automatically
Usage:
./setup_cron.shPost-setup:
- Cron job is active in your crontab
- Speed tests will run automatically at the configured interval
- Results are saved to
speedtest_results.json - Logs are written to
speedtest_cron.log
Cron job format:
*/10 * * * * cd /opt/projects/speed-test-with-graphing && /usr/bin/python3 speedtest_runner.py >> speedtest_cron.log 2>&1
What it does:
- π Creates a cron job to update MRTG graphs automatically
- β±οΈ Uses interval from
varsfile (default: every 5 minutes) - π Updates all three graphs (download, upload, ping) in sequence
- π Sets
LANG=Cto avoid MRTG UTF-8 warnings - π Uses semicolons (
;) instead of&&so all graphs update even if one fails - π Updates existing cron job if it already exists (idempotent)
When to use:
- Setting up automated graph updates
- Changing the graph update interval
- After manual cron job deletion
- When graphs aren't updating automatically
Usage:
./setup_mrtg_cron.shPost-setup:
- Cron job is active in your crontab
- MRTG graphs will update automatically at the configured interval
- All three graphs (download, upload, ping) are updated
- Graph files are regenerated in
mrtg/html/
Cron job format:
*/5 * * * * env LANG=C /usr/bin/mrtg [download config]; env LANG=C /usr/bin/mrtg [upload config]; env LANG=C /usr/bin/mrtg [ping config]
What it does:
- π Creates UserParameters config file in
/etc/zabbix/zabbix_agentd.conf.d/speedtest.conf - π Defines 11 UserParameters for speedtest metrics
- π¦ Installs
zbx-speedtest.pyscript to/usr/local/bin/ - π Sets proper file permissions and ownership
- π Restarts Zabbix agent to load new configuration
- π§ Fixes agent config Include directives if needed
- β Tests the script to ensure it works correctly
When to use:
- Setting up Zabbix monitoring for speedtest metrics
- After installing Zabbix agent on the system
- Reconfiguring Zabbix integration
- When Zabbix metrics are not being collected
Usage:
sudo ./setup_zabbix.shPost-setup:
- UserParameters config file is created and active
- Zabbix script is installed and executable
- Zabbix agent has been restarted (if service exists)
- All 11 metrics are available for collection
- Ready to configure items in Zabbix server
Available UserParameters:
speedtest.download- Latest download speedspeedtest.upload- Latest upload speedspeedtest.ping- Latest ping/latencyspeedtest.download_avg_24h- 24-hour average downloadspeedtest.upload_avg_24h- 24-hour average uploadspeedtest.ping_avg_24h- 24-hour average pingspeedtest.test_count_24h- Number of tests in last 24hspeedtest.last_test_time- Unix timestamp of last testspeedtest.server_name- Name of last test serverspeedtest.server_location- Location of last test serverspeedtest.server_country- Country of last test server
What it does:
- π Connects to speedtest.net servers
- π Automatically selects the best server based on ping
- β¬οΈ Tests download speed (in Mbps)
- β¬οΈ Tests upload speed (in Mbps)
- π‘ Measures ping/latency (in milliseconds)
- πΎ Saves results to
speedtest_results.jsonin JSON format - π Displays results to console
- π Appends to existing results (preserves history)
When to use:
- Manual speed test execution
- Testing the system
- Debugging speed test issues
- Called automatically by cron job
Usage:
python3 speedtest_runner.pyOutput:
- Console output with test results
- JSON entry added to
speedtest_results.json - Includes timestamp, speeds, ping, and server information
Post-execution:
- New test result is saved to JSON file
- Data is available for MRTG graphing
- Can be viewed in JSON file or via MRTG graphs
What it does:
- π Reads speed test results from
speedtest_results.json - π Calculates averages over the last 24 hours (configurable)
- π’ Outputs data in MRTG-compatible format (4 lines: value1, value2, uptime, system_name)
- π― Supports three metrics: download, upload, and ping
- β° Filters results by time window (default: last 24 hours)
- π Returns 0 if no data is available
When to use:
- Called automatically by MRTG (via cron job)
- Testing MRTG data output
- Debugging graph data issues
- Manual verification of calculated averages
Usage:
# Test download metric
python3 mrtg_speedtest.py --metric download
# Test upload metric
python3 mrtg_speedtest.py --metric upload
# Test ping metric
python3 mrtg_speedtest.py --metric ping
# Use custom time window (hours)
python3 mrtg_speedtest.py --metric download --hours 12Output format (MRTG standard):
473 # Value 1 (average download in Mbps)
0 # Value 2 (unused, always 0)
# Uptime (empty)
Average Download # System name
Post-execution:
- MRTG reads this output to update graphs
- Graphs reflect the calculated averages
- Data is stored in MRTG log files
What it does:
- π Reads speed test results from
speedtest_results.json - π’ Returns individual metrics for Zabbix monitoring
- π Calculates averages and statistics on demand
- β° Filters results by time windows (24 hours)
- π― Supports 11 different metrics for comprehensive monitoring
When to use:
- Called automatically by Zabbix agent (via UserParameters)
- Testing Zabbix integration
- Debugging metric collection
- Manual verification of metric values
Usage:
# Test individual metrics
/usr/local/bin/zbx-speedtest.py speedtest.download
/usr/local/bin/zbx-speedtest.py speedtest.upload
/usr/local/bin/zbx-speedtest.py speedtest.ping
/usr/local/bin/zbx-speedtest.py speedtest.download_avg_24h
/usr/local/bin/zbx-speedtest.py speedtest.test_count_24hAvailable Metrics:
speedtest.download- Latest download speed (Mbps)speedtest.upload- Latest upload speed (Mbps)speedtest.ping- Latest ping/latency (ms)speedtest.download_avg_24h- 24-hour average download (Mbps)speedtest.upload_avg_24h- 24-hour average upload (Mbps)speedtest.ping_avg_24h- 24-hour average ping (ms)speedtest.test_count_24h- Number of tests in last 24 hoursspeedtest.last_test_time- Unix timestamp of last testspeedtest.server_name- Name of last test serverspeedtest.server_location- Location of last test serverspeedtest.server_country- Country of last test server
Post-execution:
- Zabbix agent reads this output to collect metrics
- Metrics are sent to Zabbix server for monitoring
- Can be used in triggers, graphs, and dashboards
This project includes full Zabbix integration for enterprise monitoring of speed test metrics.
The Zabbix integration provides 11 UserParameters that expose speedtest metrics to your Zabbix server. This allows you to:
- π Create graphs and dashboards in Zabbix
- π¨ Set up triggers for speed anomalies
- π Track historical trends over time
- π Get alerts when speeds drop below thresholds
- Zabbix agent must be installed and running on the host
- Speed test data must exist (run
python3 speedtest_runner.pyat least once) - Root/sudo access required for installation
Method 1: Automatic Setup (Recommended)
The Zabbix integration is automatically configured when you run the master setup script:
sudo ./setup_all.shThis will set up MRTG, Apache, cron jobs, and Zabbix integration all at once.
Method 2: Manual Setup
If you want to set up Zabbix integration separately or only need Zabbix:
sudo ./setup_zabbix.shThe setup script performs the following actions:
-
Creates UserParameters Configuration:
- Location:
/etc/zabbix/zabbix_agentd.conf.d/speedtest.conf - Contents: 11 UserParameter definitions
- Permissions:
root:root,644
- Location:
-
Installs Zabbix Script:
- Source:
./zbx-speedtest.py(project directory) - Destination:
/usr/local/bin/zbx-speedtest.py - Permissions:
root:root,755(executable) - Purpose: Provides metric data to Zabbix agent
- Source:
-
Restarts Zabbix Agent:
- Automatically restarts
zabbix-agentorzabbix-agentdservice - Loads new UserParameters configuration
- Verifies agent is running
- Automatically restarts
-
Verifies Installation:
- Tests script execution
- Checks file permissions
- Validates configuration
| Component | Location | Description |
|---|---|---|
| UserParameters Config | /etc/zabbix/zabbix_agentd.conf.d/speedtest.conf |
Zabbix agent configuration file |
| Zabbix Script | /usr/local/bin/zbx-speedtest.py |
Executable script for metric collection |
| Source Script | /opt/projects/speed-test-with-graphing/zbx-speedtest.py |
Original script in project directory |
| Speedtest Data | /opt/projects/speed-test-with-graphing/speedtest_results.json |
JSON file with test results |
| Metric | Description | Unit | Example |
|---|---|---|---|
speedtest.download |
Latest download speed | Mbps | 445.79 |
speedtest.upload |
Latest upload speed | Mbps | 55.83 |
speedtest.ping |
Latest ping/latency | ms | 30.2 |
speedtest.download_avg_24h |
24-hour average download | Mbps | 473.5 |
speedtest.upload_avg_24h |
24-hour average upload | Mbps | 49.2 |
speedtest.ping_avg_24h |
24-hour average ping | ms | 28.5 |
speedtest.test_count_24h |
Number of tests in last 24h | count | 144 |
speedtest.last_test_time |
Unix timestamp of last test | timestamp | 1703941708 |
speedtest.server_name |
Name of last test server | string | "Lyons, GA" |
speedtest.server_location |
Location of last test server | string | "Unknown" |
speedtest.server_country |
Country of last test server | string | "United States" |
Before running setup, test the script from the project directory:
cd /opt/projects/speed-test-with-graphing
python3 zbx-speedtest.py speedtest.download
python3 zbx-speedtest.py speedtest.upload
python3 zbx-speedtest.py speedtest.pingExpected Output:
393.62 # Download speed in Mbps
41.33 # Upload speed in Mbps
26.01 # Ping in milliseconds
β οΈ Note: If you see0, it means no speedtest data exists yet. Runpython3 speedtest_runner.pyfirst.
Use the provided test script to test all 11 metrics:
cd /opt/projects/speed-test-with-graphing
./test_zabbix_metrics.shThis will display all metrics with their current values.
After running sudo ./setup_zabbix.sh, test from the installed location:
# Test individual metrics
/usr/local/bin/zbx-speedtest.py speedtest.download
/usr/local/bin/zbx-speedtest.py speedtest.upload
/usr/local/bin/zbx-speedtest.py speedtest.ping
/usr/local/bin/zbx-speedtest.py speedtest.download_avg_24h
/usr/local/bin/zbx-speedtest.py speedtest.upload_avg_24h
/usr/local/bin/zbx-speedtest.py speedtest.ping_avg_24h
/usr/local/bin/zbx-speedtest.py speedtest.test_count_24h
/usr/local/bin/zbx-speedtest.py speedtest.last_test_time
/usr/local/bin/zbx-speedtest.py speedtest.server_name
/usr/local/bin/zbx-speedtest.py speedtest.server_location
/usr/local/bin/zbx-speedtest.py speedtest.server_countryExpected Outputs:
- Numeric metrics: Decimal numbers or integers (e.g.,
393.62,41.33,3,1767120005) - Text metrics: Strings (e.g.,
"Thomasville, GA","United States")
This is critical - Zabbix agent runs as the zabbix user, so test with that user:
sudo -u zabbix /usr/local/bin/zbx-speedtest.py speedtest.downloadExpected: Should return the same value as when run as root (e.g., 393.62)
β οΈ If this returns0: The script may be outdated. Re-runsudo ./setup_zabbix.shto update it.
From your Zabbix server, use zabbix_get to test the agent connection:
# Replace <hostname> with your monitored host's hostname or IP
zabbix_get -s <hostname> -k speedtest.download
zabbix_get -s <hostname> -k speedtest.upload
zabbix_get -s <hostname> -k speedtest.ping
zabbix_get -s <hostname> -k speedtest.download_avg_24hExpected Output:
393.62
41.33
26.01
446.83
Check that all components are properly installed:
# Verify UserParameters config exists
cat /etc/zabbix/zabbix_agentd.conf.d/speedtest.conf
# Test agent config syntax (use -p flag, not -t)
sudo zabbix_agentd -p -c /etc/zabbix/zabbix_agentd.confNote: If the agent fails to start after setup, use the fix script:
cd /opt/projects/speed-test-with-graphing
sudo ./fix_zabbix_agent_config.shThis script will:
- Create a backup of the agent config
- Test config syntax
- Fix Include directive issues
- Remove duplicate Include lines
- Restart the agent
ls -l /usr/local/bin/zbx-speedtest.py
sudo systemctl status zabbix-agent
sudo journalctl -u zabbix-agent -n 50 | grep -i speedtest
**Expected:**
- Config file should show 11 `UserParameter=` lines
- Script should be executable (`-rwxr-xr-x`)
- Agent should be running
- No errors in logs
### π Zabbix Configuration
**1. Add Items in Zabbix:**
- Go to Configuration β Hosts β Your Host β Items
- Click "Create item"
- Use the metric names (e.g., `speedtest.download`)
- Set appropriate update interval (e.g., 10 minutes to match speedtest interval)
- Configure value types (Numeric for speeds/ping, Text for server info)
**2. Create Graphs:**
- Go to Configuration β Hosts β Your Host β Graphs
- Create graphs for download, upload, and ping speeds
- Add items for latest values and 24-hour averages
**3. Set Up Triggers:**
Example triggers:
- Download speed below 100 Mbps: `{speedtest.download}<100`
- Upload speed below 10 Mbps: `{speedtest.upload}<10`
- Ping above 100ms: `{speedtest.ping}>100`
- No tests in last 2 hours: `{speedtest.test_count_24h}<12`
**4. Create Dashboards:**
- Combine graphs, latest values, and server information
- Add widgets for real-time monitoring
### π Post-Setup
After setup:
- β
UserParameters are active and ready to use
- β
Zabbix agent has been restarted (if service exists)
- β
Script is installed and executable
- β
Configuration file is in place
**Next Steps:**
1. Verify metrics are being collected in Zabbix
2. Create items for the metrics you want to monitor
3. Set up graphs and dashboards
4. Configure triggers for alerts
### π Troubleshooting
**Metric returns 0 or empty:**
- Check if speedtest data exists: `cat speedtest_results.json`
- Verify script path: `ls -l /usr/local/bin/zbx-speedtest.py`
- Test script manually: `/usr/local/bin/zbx-speedtest.py speedtest.download`
**Zabbix agent can't collect metrics:**
- Check agent logs: `sudo journalctl -u zabbix-agent -n 50`
- Verify UserParameters config: `cat /etc/zabbix/zabbix_agentd.conf.d/speedtest.conf`
- Test config syntax: `sudo zabbix_agentd -p -c /etc/zabbix/zabbix_agentd.conf`
- If agent fails to start: `sudo ./fix_zabbix_agent_config.sh`
- Restart agent: `sudo systemctl restart zabbix-agent`
- Check script permissions: `ls -l /usr/local/bin/zbx-speedtest.py`
**Script not found:**
- Re-run setup: `sudo ./setup_zabbix.sh`
- Verify script exists: `ls -l /usr/local/bin/zbx-speedtest.py`
---
## π Usage
### π Manual Speed Test
Run a single speed test manually:
```bash
python3 speedtest_runner.py
Output example:
Selecting best server...
Testing download speed...
Testing upload speed...
Result saved to /opt/projects/speed-test-with-graphing/speedtest_results.json
==================================================
Speed Test Results:
==================================================
Download: 445.79 Mbps
Upload: 55.83 Mbps
Ping: 30.2 ms
Server: Lyons, GA (Unknown)
Timestamp: 2025-12-30T13:08:28.903570
==================================================
After setup, graphs are available via web browser:
- Main page:
http://YOUR_IP_ADDRESS/mrtg/ - Download speed:
http://YOUR_IP_ADDRESS/mrtg/download.html - Upload speed:
http://YOUR_IP_ADDRESS/mrtg/upload.html - Ping/Latency:
http://YOUR_IP_ADDRESS/mrtg/ping.html
π‘ Tip: Replace
YOUR_IP_ADDRESSwith the IP address you configured in thevarsfile.
Graph Features:
- π Daily Graph: 5-minute averages over 24 hours
- π Weekly Graph: 30-minute averages over 7 days
- π Monthly Graph: 2-hour averages over 30 days
- π Yearly Graph: Daily averages over 1 year
Note: Apache is configured to listen on the IP address and port specified in your vars file. The firewall is automatically configured to allow traffic on that IP and port.
Test the MRTG data output script:
# Test download metric
python3 mrtg_speedtest.py --metric download
# Test upload metric
python3 mrtg_speedtest.py --metric upload
# Test ping metric
python3 mrtg_speedtest.py --metric pingExpected output:
473 # Average value (varies based on your data)
0 # Always 0 (unused)
# Empty line
Average Download # Metric name
speed-test-with-graphing/
βββ π speedtest_runner.py # Runs speed tests and saves to JSON
βββ π mrtg_speedtest.py # Outputs speedtest data in MRTG format
βββ π zbx-speedtest.py # Outputs speedtest data for Zabbix
βββ π requirements.txt # Python dependencies
βββ π vars.example # Configuration template (committed to git)
βββ π vars # Your configuration (ignored by git)
β
βββ π§ setup_all.sh # Master setup script (runs all below)
βββ π§ setup_mrtg.sh # Sets up MRTG and Apache
βββ π§ setup_cron.sh # Sets up speedtest cron job
βββ π§ setup_mrtg_cron.sh # Sets up MRTG update cron job
βββ π§ setup_zabbix.sh # Sets up Zabbix integration
β
βββ π speedtest_results.json # All test results (ignored by git)
βββ π speedtest_cron.log # Speedtest execution logs
β
βββ π mrtg/ # MRTG directory (ignored by git)
βββ π cfg/ # MRTG configuration files
β βββ speedtest-download.cfg
β βββ speedtest-upload.cfg
β βββ speedtest-ping.cfg
βββ π html/ # Generated HTML and graph files
β βββ index.html # Landing page
β βββ download.html # Download speed graph page
β βββ upload.html # Upload speed graph page
β βββ ping.html # Ping graph page
β βββ *.png # Graph images (day/week/month/year)
β βββ *.log # MRTG data logs
βββ π logs/ # MRTG execution logs
βββ π work/ # MRTG working directory
Results are stored in JSON format with the following structure:
[
{
"timestamp": "2024-01-15T10:30:00",
"download_mbps": 95.42,
"upload_mbps": 12.35,
"ping_ms": 15.2,
"server": {
"name": "Server Name",
"location": "City, Country",
"country": "Country"
}
}
]Fields:
timestamp: ISO 8601 format timestamp (UTC timezone-aware format, e.g.,2025-12-30T22:10:21+00:00)download_mbps: Download speed in Megabits per secondupload_mbps: Upload speed in Megabits per secondping_ms: Latency in millisecondsserver: Information about the test server used
Note on Timestamps:
- New tests store timestamps in UTC format with timezone information (
+00:00) - Old tests may have naive timestamps (without timezone) - these are automatically converted to UTC when read
- This ensures consistent time display across MRTG and Zabbix regardless of server timezone
MRTG graphs display:
- π₯ Average Download Speed (Mbps) - averaged over last 24 hours
- π€ Average Upload Speed (Mbps) - averaged over last 24 hours
- π‘ Average Ping (ms) - averaged over last 24 hours
Graph Types:
- Daily: 5-minute averages, 24-hour view
- Weekly: 30-minute averages, 7-day view
- Monthly: 2-hour averages, 30-day view
- Yearly: Daily averages, 1-year view
Graphs are updated at the interval specified in your vars file (default: every 5 minutes).
The setup scripts create cron jobs based on your vars file configuration:
Default: Every 10 minutes
What it does:
- Runs
speedtest_runner.py - Saves results to
speedtest_results.json - Logs output to
speedtest_cron.log
Cron format:
*/10 * * * * cd /path/to/project && /usr/bin/python3 speedtest_runner.py >> speedtest_cron.log 2>&1
Post-execution:
- New speed test result added to JSON
- Data available for MRTG graphing
- Log entry in
speedtest_cron.log
Default: Every 5 minutes
What it does:
- Updates download speed graph
- Updates upload speed graph
- Updates ping graph
- Regenerates HTML pages
- Updates PNG graph images
Cron format:
*/5 * * * * env LANG=C /usr/bin/mrtg [download config]; env LANG=C /usr/bin/mrtg [upload config]; env LANG=C /usr/bin/mrtg [ping config]
Post-execution:
- Graph images updated (PNG files)
- HTML pages regenerated
- MRTG log files updated
- Graphs reflect latest averages
All setup scripts are idempotent, meaning they can be run multiple times safely:
β Safe to re-run:
- They check for existing configurations before creating new ones
- They update existing configurations if needed
- They won't create duplicate cron jobs
- They won't break if components are already installed
- They validate and fix permissions if needed
Benefits:
- π‘οΈ Safe to run after system updates
- π Easy to reconfigure settings
- π Can fix issues by re-running setup
- π No manual cleanup required
- Python 3.7+ - For running speed tests
- Internet connection - Required for speed tests
- Root/sudo access - For Apache and MRTG setup
- speedtest-cli - Python package (installed via requirements.txt)
- MRTG - Installed automatically by setup script
- Apache/HTTPD - Installed automatically by setup script
System Support:
- β RHEL/CentOS (tested on RHEL 10)
- β Debian/Ubuntu
- β Other Linux distributions with yum/apt-get
crontab -ltail -f speedtest_cron.logtail -f mrtg/logs/speedtest-*.logpython3 mrtg_speedtest.py --metric download
python3 mrtg_speedtest.py --metric upload
python3 mrtg_speedtest.py --metric ping# RHEL/CentOS
sudo systemctl restart httpd
# Debian/Ubuntu
sudo systemctl restart apache2cat varssudo systemctl status httpd # RHEL/CentOS
sudo systemctl status apache2 # Debian/Ubuntu# firewalld
sudo firewall-cmd --list-all
# ufw
sudo ufw status
# iptables
sudo iptables -L -nls -la mrtg/html/
ls -laZ mrtg/html/ # SELinux contextsudo ./setup_all.sh./check_zabbix_last_check.shThis script shows:
- Zabbix agent running status
- Last log activity
- Recent errors/warnings
- Instructions for checking when Zabbix server last collected data
Solution:
- Wait for more speed test results (need multiple data points)
- Verify
speedtest_results.jsonhas data:cat speedtest_results.json - Check MRTG logs for errors:
tail mrtg/logs/speedtest-*.log
Solution:
- Run
sudo ./setup_mrtg.shto fix permissions - Check SELinux context:
ls -laZ mrtg/html/ - Verify firewall allows traffic
Solution:
- Verify cron service is running:
systemctl status crond - Check cron logs:
grep CRON /var/log/messages - Re-run setup:
./setup_cron.shor./setup_mrtg_cron.sh
Solution:
- Check internet connectivity
- Verify speedtest-cli is installed:
pip list | grep speedtest - Check logs:
tail speedtest_cron.log
MIT License - feel free to use and modify as needed!
Contributions are welcome! Please ensure all scripts remain idempotent and follow the existing code style.
Made with β€οΈ for network monitoring and speed testing