Skip to content

Larsy93/openwrt-speedtest-go-discord-webhook-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OpenWrt Speedtest-go to Discord Webhook Script

OpenWrt License: MIT

A high-performance, resource-optimized shell script for routers running OpenWrt or pretty much any other linux device. It executes a network speed test using speedtest-go and sends a detailed, formatted report to a Discord channel via Webhooks.

Example Discord Message(It even has full UTF-8 emoji support!)

Speedtest Discord Report


🚀 Key Features

  • Robust JQ Parsing Now uses jq for reliable JSON processing. This ensures that special characters in server names or ISP data don't break the script, while maintaining high performance.

  • Advanced Packet Loss Analysis Includes specialized logic to process the relationship between sent and received packets. This ensures high-precision reporting (0.00%) by correctly identifying control packets and data flow.

  • ICMP Precision Uses ICMP ping mode for more accurate latency measurements, avoiding the overhead of HTTP/TCP handshakes.

  • Smart Formatting Reports Download, Upload, Ping (Min/Avg/Max), Jitter, and Packet Loss in a clean, code-blocked Discord message.


🛠 Prerequisites

Before installing, ensure the following packages are installed on your router:

opkg update
opkg install speedtest-go curl jq

📦 Installation

  1. Download the script and place speedtestdiscord.sh in the /root/ directory.

  2. Make the script executable:

    chmod +x /root/speedtestdiscord.sh

  3. Edit the script and configure the following variables:

  • WEBHOOK_URL – Your Discord Webhook URL
  • FRIENDLY_NAME – Name of your router or location (e.g. Home Router)
  • DISCORD_USER – Username displayed by the Discord bot

⏱ Automation (Cron)

To run the speed test automatically every hour, add the following scheduled task via LuCI or crontab -e:

0 * * * * /root/speedtestdiscord.sh

🛠 Why this script?

  1. Security: No use of eval, eliminating potential shell injection risks.
  2. Reliability: Proper JSON handling regardless of the input data format.
  3. Efficiency: Data is parsed in a single stream, keeping CPU overhead minimal even on budget routers.

The script is specifically tuned for the speedtest-go implementation, ensuring that unit conversions (Bytes to Mbps) and latency (Nanoseconds to Milliseconds) are calculated with high precision.


📜 Credits

This script relies on the excellent speedtest-go tool developed by showwin.
All speed measurement logic is handled by their Go-based Speedtest CLI implementation.

https://github.com/showwin/speedtest-go


Created with a focus on performance, accuracy, and OpenWrt-friendly design.

About

A high-performance, resource-optimized OpenWrt speed test script using speedtest-go. Sends detailed reports with ICMP precision to Discord via Webhooks. Built for low CPU/Memory impact.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages