- Python 36.9%
- JavaScript 29%
- PHP 14.3%
- Volt 13%
- Shell 6.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| locale/ru_RU/LC_MESSAGES | ||
| src/opnsense | ||
| tools | ||
| .gitattributes | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| TODO.md | ||
| VERSION | ||
os-kspeedtest
Self-contained speed measurement plugin for OPNsense: measures WAN speed on the router itself, keeps a local history and exposes the results through its own API. It knows nothing about any external panel — consumers (e.g. KVRP) poll the plugin API if it is enabled.
Features
- Providers (selectable in settings):
- Yandex Internetometer — built-in, stdlib only (duration-based: 8 download threads × 6 s + 2 upload threads × 3 s);
- Ookla Speedtest — uses the
speedtestbinary (pkg install ookla-speedtest) orspeedtest-cliwhen present; skipped gracefully otherwise.
- Multi-WAN: optional WAN profiles measure through specific interfaces
(source address binding); results are reported as
provider@name, e.g.yandex@lte. Per profile: lite measurement (less traffic: 2×2 s + 1×1 s) and minimum interval (skip if measured recently — combine with cron to save LTE traffic). Ookla binding requires the officialspeedtestbinary. - Jitter and network info: latency is measured 5 times on the fastest probe (jitter = mean difference of consecutive samples); each run also records the egress IP, ISP/ASN and region per WAN (via ip-api.com, best-effort).
- Configurable durations: download/upload phase length (defaults 6 s / 3 s); lite profiles use fixed 2 s / 1 s. Measure default route toggle avoids duplicates when a WAN profile already covers the main uplink.
- Two dashboard widgets (OPNsense ≥ 25.7): KSpeedtest: Measure — button with live stage/speed and Stop; KSpeedtest: History — dual-ring gauge cards per WAN (inner download / outer upload, tick scale, ping+jitter, ISP/region, per-card Measure button), history list and speed/ping charts on a real time scale (range: 6 h … 3 months, log scale option, per-point tooltips).
- Per-WAN measurements:
service/start?wan=<name>measures a single profile (bypasses its min interval) and merges the result intolast.json; the History widget has a button per card. - External consumers API (toggleable):
/api/kspeedtest/service/last,/history?limit=N,/config(providers, durations, WAN profiles),service/clearhistory— authenticated with regular OPNsense API keys. - Tiered local history in
/var/db/kspeedtest/: raw entries up to 2 days (configurable count, 10–2000), then decimated tiers — every 2nd sample moves to the 2–7 day tier, every 2nd of those to 7–30 days, and so on, keeping up to 90 days of history for long-range charts. - Tabbed settings page: General (grouped: measurement settings / providers / schedule / misc) | WAN profiles (with WAN auto-detect) | History (date filter, page size, pagination, clear history).
- Localized UI — follows the OPNsense language setting (English source strings,
Russian catalog shipped; more languages: add
locale/<lang>/LC_MESSAGES/kspeedtest.po). - Cron integration: the
KSpeedtest: measure speedcommand appears automatically in System → Settings → Cron; background runs write live progress that the Measure widget shows.
Installation (on OPNsense, as root)
Download install.sh from the release straight on the router and run it.
Note the Forgejo URL layout: /releases/download/<tag>/<asset> — the latest
release is /releases/download/latest/... (unlike GitHub's /releases/latest/download/):
fetch -o /root/install.sh https://<git-host>/<owner>/os-kspeedtest/releases/download/latest/install.sh
sh /root/install.sh
To pin a specific version, replace latest with the tag (e.g. v0.1.0).
For a private repository pass an access token via curl (read:repository is enough;
FreeBSD fetch cannot send custom headers):
curl -sfL -H "Authorization: token <token>" -o /root/install.sh \
https://<git-host>/<owner>/os-kspeedtest/releases/download/v0.1.0/install.sh
sh /root/install.sh
The script is self-contained (the plugin tree is embedded), idempotent, and copies
itself to /usr/local/sbin/kspeedtest-install.sh so it is always available:
sh /usr/local/sbin/kspeedtest-install.sh uninstall # removal
After installing:
- Re-login to the web UI (the menu is built at login), open Services → KSpeedtest.
- Pick providers, Save, verify with Measure now.
- Optional schedule: System → Settings → Cron → +, command KSpeedtest: measure speed (mind the traffic: ~25 MB per Yandex run).
- Optional: add the KSpeedtest: History / KSpeedtest: Measure widgets on the dashboard (Lobby → Dashboard).
Manual run from the console: configctl kspeedtest measure
API
GET /api/kspeedtest/service/last # latest measurement (per-WAN merged)
GET /api/kspeedtest/service/history?limit=50 # history, tiers merged (newest last)
POST /api/kspeedtest/service/start # background measurement
POST /api/kspeedtest/service/start?wan=lte # measure one WAN profile only
POST /api/kspeedtest/service/clearhistory # wipe all history tiers
GET /api/kspeedtest/settings/detect_wan # guess WAN interfaces from config
Result format:
{
"timestamp": "2026-10-28T12:00:00Z",
"providers": {
"yandex": {"downloadMbps": 93.1, "uploadMbps": 88.4, "latencyMs": 12.3, "jitterMs": 1.8},
"ookla": {"downloadMbps": 94.0, "uploadMbps": 90.1, "latencyMs": 9.8, "server": "Example ISP"},
"yandex@lte": {"downloadMbps": 31.2, "uploadMbps": 12.5, "latencyMs": 45.1, "jitterMs": 6.3}
},
"networks": {
"default": {"ip": "203.0.113.10", "isp": "Example ISP", "asn": 12345, "country": "…", "region": "…", "city": "…"},
"lte": {"ip": "198.51.100.7", "isp": "Mobile Operator", "asn": 31133, "country": "…", "region": "…", "city": "…"}
}
}
A provider that failed reports {"error": "..."} instead. The API is enabled in
settings by default and can be switched off ("Results API") — the UI then shows a
hint instead of history.
Uninstall
sh /usr/local/sbin/kspeedtest-install.sh uninstall
Removes the plugin files and restarts configd. Measurement history in
/var/db/kspeedtest/ is kept; settings in config.xml can be cleared from the
plugin page before removal.
Development
Layout: src/opnsense/... mirrors /usr/local/opnsense/... (MVC app, configd
actions, templates, widget). The measurement script is
src/opnsense/scripts/OPNsense/Kspeedtest/kspeedtest.py (Python stdlib only;
testable off-router via KSPEEDTEST_CONFIG / KSPEEDTEST_STATE_DIR env vars).
sh tools/build-install.sh # -> dist/install.sh (compiles locale/*.po)
sh tools/publish-release.sh v0.1.0 # bump VERSION, build, commit, tag
sh tools/publish-release.sh v0.1.0 --forgejo-release
# + push and create a Forgejo release
# (env: FORGEJO_URL, FORGEJO_REPO, FORGEJO_TOKEN)
Translations: edit locale/<lang>/LC_MESSAGES/kspeedtest.po; tools/po2mo.py
compiles catalogs during the build (Python 3, no gettext-tools needed).