mirror of
https://github.com/roacn/openwrt-packages.git
synced 2025-01-08 11:57:31 +08:00
✨ Sync 2023-09-16 23:35
This commit is contained in:
parent
8ad642688e
commit
0856185ec1
21
luci-app-netspeedtest/Makefile
Normal file
21
luci-app-netspeedtest/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
# Copyright (C) 2020-2021 sirpdboy <herboy2008@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-netspeedtest
|
||||
|
||||
LUCI_TITLE:=LuCI Support for netspeedtest
|
||||
LUCI_DEPENDS:=+python3 +iperf3 +homebox +netperf
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=2.1.3
|
||||
PKG_RELEASE:=20230302
|
||||
PKG_MAINTAINER:=<https://github.com/sirpdboy/netspeedtest>
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
162
luci-app-netspeedtest/README.md
Normal file
162
luci-app-netspeedtest/README.md
Normal file
@ -0,0 +1,162 @@
|
||||
## luci-app-netspeedtest
|
||||
|
||||
### 访问数:[![](https://visitor-badge.glitch.me/badge?page_id=sirpdboy-visitor-badge)] [![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ)
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明1.jpg)
|
||||
|
||||
luci-app-netspeedtest 网络速度诊断测试(包括:内网网页版测速、内网iperf3吞吐测速、外网speedtest.net网速测试、特定服务器的端口延迟测速)
|
||||
|
||||
[luci-app-netspeedtest 网络速度诊断测试](https://github.com/sirpdboy/netspeedtest)
|
||||
|
||||
请 **认真阅读完毕** 本页面,本页面包含注意事项和如何使用。
|
||||
|
||||
## 写在前面
|
||||
|
||||
- 一直在找OPENWRT上测试速度的插件,苦寻不到,于是有了它! 此插件可进行内外和外网网络速度测试。
|
||||
- TG群友说插件2年没更新了,花了几天时间结合时下需要,将网络测试功能升级到2.0版本。
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
## [菜单向导](#luci-app-netspeedtest)
|
||||
- [功能说明](#功能说明)
|
||||
- [注意事项](#iperf3吞吐测试注意事项)
|
||||
- [版本说明](#版本说明)
|
||||
- [使用方法](#使用方法)
|
||||
- [源码说明](#源码说明)
|
||||
- [界面](#界面)
|
||||
- [其它](#其它)
|
||||
- [感谢](#感谢)
|
||||
- [捐助](#捐助)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## 功能说明
|
||||
- 内网网页版测速插件 :基于speedtest-web网页版,启用后再点start进行测速。网页版启动后程序会驻留内存不测速建议不启用服务。
|
||||
- 内网iperf3吞吐测试 ,服务端路由器如果没有安装请先安装此iperf3插件。
|
||||
- 外网测速使用speedtest.net测速内核,基于speedtest-cli,需要有python3才能执行。
|
||||
- 特定服务器的端口延迟测速,是测试指定服务器的端口的延迟情况。
|
||||
|
||||
## iperf3吞吐测试注意事项
|
||||
- 测速的终端使用机器必须和测速服务器在同一个局域网络中!
|
||||
- 客户端使用步骤:启动测速服务器端-->下载测试客户端-->运行测速客户端-->输入服务端IP地址-->查看结果。
|
||||
- 客户端运行,国内端下载中有“iperf3测速客户端”,运行它输入服务器IP即可。
|
||||
国外原版,需要手动进入 CMD命令模式,再输入命令:iperf3.exe -c 服务器IP
|
||||
- 网络测速iperf3客户端下载地址:https://sipdboy.lanzoui.com/b01c3esih 密码:cpd6
|
||||
- 需要依赖: python3 iperf3 speedtest-web
|
||||
|
||||
## 版本说明
|
||||
|
||||
|
||||
### 2023.3.2 网速测试V2.1.3:
|
||||
- 修复测速Speedtest看不到测试报名问题。
|
||||
- 重新调试IPERF3测试页面代码,解决某些主题显示不优雅的问题。
|
||||
- 修复取消服务自动启用的问题
|
||||
|
||||
### 2023.1.15 网速测试V2.1:
|
||||
- 内网测试速度WEB页采用homebox。
|
||||
- 修复WEB页内网测试自动启用问题。
|
||||
- 外网测速加入Netperf测试。
|
||||
- 外网测速Speedtest某些节点会禁止测速。要测速建议关了留国的插件。
|
||||
|
||||
### 2022.10.18 网速测试V2.0.3:
|
||||
- 代码基本重写和优化。
|
||||
- Iperf3可实时体现服务状态。
|
||||
- 增加内网测试网页版。
|
||||
- 外网测速,加入更详细测试报告。
|
||||
|
||||
### 2021.3.2 网速测试V1.6:
|
||||
- 升级宽带测试带2.13内核。
|
||||
- 解决1.806以上版本不能编译问题。
|
||||
|
||||
## 使用方法
|
||||
|
||||
将NetSpeedTest 主题添加至 LEDE/OpenWRT 源码的方法。
|
||||
|
||||
### 下载源码:
|
||||
|
||||
# 下载源码
|
||||
|
||||
git clone https://github.com/sirpdboy/netspeedtest.git package/netspeedtest
|
||||
make menuconfig
|
||||
|
||||
```
|
||||
### 配置菜单
|
||||
|
||||
```Brach
|
||||
make menuconfig
|
||||
# 找到 LuCI -> Applications, 选择 luci-app-netspeedtest, 保存后退出。
|
||||
```
|
||||
|
||||
### 编译
|
||||
|
||||
```Brach
|
||||
# 编译固件
|
||||
make package/netspeedtest/luci-app-netspeedtest/compile V=s
|
||||
```
|
||||
|
||||
|
||||
## 源码说明
|
||||
|
||||
- 源码来源和依赖:
|
||||
- luci-app-netspeedtest:https://github.com/sirpdboy/netspeedtest
|
||||
- speedtest-web:https://github.com/ZeaKyX/speedtest-web
|
||||
- speedtest-cl:https://github.com/sivel/speedtest-cli
|
||||
|
||||
- 你可以随意使用其中的源码,但请注明出处。
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明2.jpg)
|
||||
|
||||
## 界面
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest1.jpg)
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest2.jpg)
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest3.jpg)
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest4.jpg)
|
||||
|
||||
|
||||
|
||||
## 使用与授权相关说明
|
||||
|
||||
- 本人开源的所有源码,任何引用需注明本处出处,如需修改二次发布必告之本人,未经许可不得做于任何商用用途。
|
||||
|
||||
|
||||
# My other project
|
||||
|
||||
- 网络速度测试 :https://github.com/sirpdboy/NetSpeedTest
|
||||
|
||||
- 定时设置插件 : https://github.com/sirpdboy/luci-app-autotimeset
|
||||
|
||||
- 关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice
|
||||
|
||||
- opentopd主题 : https://github.com/sirpdboy/luci-theme-opentopd
|
||||
|
||||
- kucat 主题: https://github.com/sirpdboy/luci-theme-kucat
|
||||
|
||||
- 家长控制: https://github.com/sirpdboy/luci-theme-parentcontrol
|
||||
|
||||
- 系统高级设置 : https://github.com/sirpdboy/luci-app-advanced
|
||||
|
||||
- ddns-go动态域名: https://github.com/sirpdboy/luci-app-ddns-go
|
||||
|
||||
- 进阶设置(系统高级设置+主题设置kucat/agron/opentopd): https://github.com/sirpdboy/luci-app-advancedplus
|
||||
|
||||
- 设置向导: https://github.com/sirpdboy/luci-app-wizard
|
||||
|
||||
- 分区扩容: https://github.com/sirpdboy/luci-app-partexp
|
||||
|
||||
- lukcy大吉: https://github.com/sirpdboy/luci-app-lukcy
|
||||
|
||||
## 捐助
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明3.jpg)
|
||||
|
||||
| <img src="https://img.shields.io/badge/-支付宝-F5F5F5.svg" href="#赞助支持本项目-" height="25" alt="图飞了😂"/> | <img src="https://img.shields.io/badge/-微信-F5F5F5.svg" height="25" alt="图飞了😂" href="#赞助支持本项目-"/> |
|
||||
| :-----------------: | :-------------: |
|
||||
|![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/支付宝.png) | ![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/微信.png) |
|
||||
|
||||
<a href="#readme">
|
||||
<img src="https://img.shields.io/badge/-返回顶部-orange.svg" alt="图飞了😂" title="返回顶部" align="right"/>
|
||||
</a>
|
92
luci-app-netspeedtest/luasrc/controller/netspeedtest.lua
Normal file
92
luci-app-netspeedtest/luasrc/controller/netspeedtest.lua
Normal file
@ -0,0 +1,92 @@
|
||||
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
|
||||
module("luci.controller.netspeedtest", package.seeall)
|
||||
local fs=require"nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
function index()
|
||||
entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "homebox"),_("Net Speedtest"), 90).dependent = true
|
||||
entry({"admin","network","netspeedtest","homebox"},cbi("netspeedtest/homebox"),_("Lan homebox Web"),20).leaf = true
|
||||
entry({"admin","network","netspeedtest","speedtestiperf3"},cbi("netspeedtest/speedtestiperf3", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Lan Speedtest Iperf3"),30).leaf = true
|
||||
entry({"admin","network","netspeedtest","speedtestwan"},cbi("netspeedtest/speedtestwan", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Wan Speedtest"), 40).leaf = true
|
||||
entry({"admin","network","netspeedtest","netperftestwan"},cbi("netspeedtest/netperftestwan", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Netperf Speedtest"), 40).leaf = true
|
||||
|
||||
entry({"admin", "network", "netspeedtest", "checknet"}, call("check_net"))
|
||||
entry({"admin", "network", "homebox_status"}, call("homebox_status"))
|
||||
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
|
||||
|
||||
entry({"admin", "network","test_iperf0"}, post("test_iperf0"), nil).leaf = true
|
||||
entry({"admin", "network","test_iperf1"}, post("test_iperf1"), nil).leaf = true
|
||||
|
||||
entry({"admin","network","netspeedtest", "speedtestrun"}, call("speedtestrun"))
|
||||
entry({"admin","network","netspeedtest", "netperfrun"}, call("netperfrun"))
|
||||
|
||||
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
|
||||
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
|
||||
end
|
||||
|
||||
|
||||
function homebox_status()
|
||||
local e = {
|
||||
run = (sys.call("pidof homebox >/dev/null") == 0),
|
||||
port = 3300
|
||||
}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function iperf3_status()
|
||||
local e={}
|
||||
e.run=sys.call("pgrep iperf3 >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function testout(cmd, addr)
|
||||
luci.http.prepare_content("text/plain")
|
||||
local util = io.popen(cmd)
|
||||
if util then
|
||||
while true do
|
||||
local ln = util:read("*l")
|
||||
if not ln then break end
|
||||
luci.http.write(ln)
|
||||
luci.http.write("\n")
|
||||
end
|
||||
util:close()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function test_iperf0(addr)
|
||||
sys.call("pgrep -f unblockneteasemusic | xargs kill -9 >/dev/null 2>&1 ")
|
||||
sys.call("/etc/init.d/unblockneteasemusic stop ")
|
||||
sys.call("/etc/init.d/unblockmusic stop ")
|
||||
testout("iperf3 -s ", addr)
|
||||
end
|
||||
|
||||
function test_iperf1(addr)
|
||||
sys.call("pgrep -f iperf3 | xargs kill -9 >/dev/null 2>&1 ")
|
||||
sys.call("/etc/init.d/unblockneteasemusic restart")
|
||||
sys.call("/etc/init.d/unblockmusic restart")
|
||||
end
|
||||
|
||||
function get_log()
|
||||
local e = {}
|
||||
e.running = sys.call("busybox ps -w | grep netspeedtest | grep -v grep >/dev/null") == 0
|
||||
e.log = fs.readfile("/var/log/netspeedtest.log") or ""
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function dellog()
|
||||
fs.writefile("/var/log/netspeedtest.log","")
|
||||
http.prepare_content("application/json")
|
||||
http.write('')
|
||||
end
|
||||
|
||||
function speedtestrun()
|
||||
testout("/etc/init.d/netspeedtest nstest ")
|
||||
end
|
||||
|
||||
function netperfrun()
|
||||
testout("sh /usr/bin/netperftest")
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
|
||||
local m, s ,o
|
||||
|
||||
|
||||
m = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
|
||||
-- m:section(SimpleSection).template = "netspeedtest/homebox_status"
|
||||
|
||||
s = m:section(TypedSection, "homebox", translate('Lan homebox Web'))
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
|
||||
o=s:option(Flag,"enabled",translate("Enable"))
|
||||
o.default=0
|
||||
|
||||
o = s:option(DummyValue, '', '')
|
||||
o.rawhtml = true
|
||||
o.template ='netspeedtest/homebox'
|
||||
|
||||
m.apply_on_parse = true
|
||||
m.on_after_apply = function(self,map)
|
||||
io.popen("/etc/init.d/netspeedtest start")
|
||||
end
|
||||
|
||||
return m
|
@ -0,0 +1,18 @@
|
||||
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
require("luci.util")
|
||||
local o,t,e
|
||||
|
||||
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
|
||||
|
||||
t=o:section(TypedSection,"wanspeedtest",translate("Netperf Speedtest"))
|
||||
t.anonymous=true
|
||||
|
||||
e = t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template ='netspeedtest/netperftestwan'
|
||||
|
||||
e =t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template = 'netspeedtest/log'
|
||||
|
||||
return o
|
@ -0,0 +1,18 @@
|
||||
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
require("luci.util")
|
||||
local o,s,e
|
||||
|
||||
|
||||
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
|
||||
o:section(SimpleSection).template = "netspeedtest/speedtestiperf3_status"
|
||||
|
||||
s = o:section(TypedSection, "speedtestiperf3", translate('Lan Speedtest Iperf3'))
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
|
||||
e = s:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template ='netspeedtest/speedtestiperf3'
|
||||
|
||||
|
||||
return o
|
@ -0,0 +1,18 @@
|
||||
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
require("luci.util")
|
||||
local o,t,e
|
||||
|
||||
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
|
||||
|
||||
t=o:section(TypedSection,"wanspeedtest",translate("Wan Speedtest"))
|
||||
t.anonymous=true
|
||||
|
||||
e = t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template ='netspeedtest/speedtestwan'
|
||||
|
||||
e =t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template = 'netspeedtest/log'
|
||||
|
||||
return o
|
18
luci-app-netspeedtest/luasrc/view/netspeedtest/homebox.htm
Normal file
18
luci-app-netspeedtest/luasrc/view/netspeedtest/homebox.htm
Normal file
@ -0,0 +1,18 @@
|
||||
<%#
|
||||
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
|
||||
https://github.com/sirpdboy/netspeedtest
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%+cbi/valueheader%>
|
||||
<div class="cbi-map">
|
||||
<iframe id="homebox" style="width: 100%; min-height: 400px; border: none; border-radius: 3px;"></iframe>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
document.getElementById("homebox").src = window.location.protocol + "//" + window.location.hostname + ":3300";
|
||||
document.getElementById("homebox").height = document.documentElement.clientHeight;
|
||||
window.onresize = function(){
|
||||
document.getElementById("homebox").height = document.documentElement.clientHeight;
|
||||
}
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,28 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[network]], [[homebox_status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('homebox_status');
|
||||
if (data && tb)
|
||||
{
|
||||
if (data.run)
|
||||
{
|
||||
tb.innerHTML = '<br/><em style=\"color:green\"><%:The homebox service is running.%></em>';
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.innerHTML = '<br/><em style=\"color:red\"><%:The homebox service is not running.%></em>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]></script>
|
||||
|
||||
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:homebox Status%></legend>
|
||||
<p id="homebox_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
16
luci-app-netspeedtest/luasrc/view/netspeedtest/log.htm
Normal file
16
luci-app-netspeedtest/luasrc/view/netspeedtest/log.htm
Normal file
@ -0,0 +1,16 @@
|
||||
<%+cbi/valueheader%>
|
||||
<textarea id="logview.list" class="cbi-input-textarea" style="width: 100%" rows="20" readonly="readonly"></textarea>
|
||||
|
||||
<script type="text/javascript">
|
||||
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","realtime_log")%>';
|
||||
|
||||
XHR.poll(1, LOG_URL, null, (x, d) => {
|
||||
let logview = document.getElementById("logview.list");
|
||||
if (!d.running) {
|
||||
XHR.halt();
|
||||
}
|
||||
logview.value = d.log;
|
||||
logview.scrollTop = logview.scrollHeight;
|
||||
});
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,54 @@
|
||||
<%#
|
||||
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
|
||||
https://github.com/sirpdboy/netspeedtest
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
<%
|
||||
local fs = require "nixio.fs"
|
||||
local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
|
||||
%>
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
|
||||
<input class="cbi-button cbi-button-apply" id="netperf_service" type="button" onclick="netperf()" value="<%= translate('Perform Netperf Speedtest') %>" />
|
||||
|
||||
<fieldset class="cbi-section" style="display:none">
|
||||
<legend id="netperftest-legend">
|
||||
<%:Collecting data...%>
|
||||
</legend>
|
||||
<span id="netperftest-output"></span>
|
||||
</fieldset>
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","netperfrun")%>';
|
||||
const S_URL = '<%=luci.dispatcher.build_url("admin","network","netspeedtest","netperftestwan")%>';
|
||||
function netperf(s) {
|
||||
var legend = document.getElementById('netperftest-legend');
|
||||
var output = document.getElementById('netperftest-output');
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
|
||||
'<%:Network speed test, please wait...%>'
|
||||
;
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
XHR.get(RUN_URL, null,
|
||||
function(x)
|
||||
{
|
||||
if (x.responseText)
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
|
||||
}
|
||||
else
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML ='</p><%:Operation execution complete%></p>';
|
||||
}
|
||||
setTimeout(() => { window.location = S_URL }, 5000);
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,80 @@
|
||||
<%#
|
||||
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
|
||||
https://github.com/sirpdboy/netspeedtest
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js?v=1.1"></script>
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
var stxhr = new XHR();
|
||||
function update_status(field, proto)
|
||||
{
|
||||
var tool = field.name;
|
||||
var addr = field.value;
|
||||
var protocol = proto ;
|
||||
var legend = document.getElementById('test-iperf-legend');
|
||||
var output = document.getElementById('test-iperf-output');
|
||||
if (legend && output)
|
||||
{
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
|
||||
'<%:Waiting for command to complete...%>';
|
||||
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
|
||||
stxhr.post('<%=url('admin/network')%>/test_' + tool + protocol + '/' + addr, { token: '<%=token%>' },
|
||||
function(x)
|
||||
{
|
||||
if (x.responseText)
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
|
||||
}
|
||||
else
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML ='</p> <%:Operation execution complete%></p>';
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<form method="post" action="<%=url('admin/network/netspeedtest')%>">
|
||||
|
||||
<div class="cbi-section-node" >
|
||||
<div class="cbi-value" >
|
||||
<label class="cbi-value-title" ><%:Select function%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input style="margin: 5px 0" type="hidden" value="" name="iperf" />
|
||||
<select name="iperf_to" style="width:auto">
|
||||
<option value="0" selected="selected"><%:iperfstart%></option>
|
||||
<option value="1"><%:iperfstop%></option>
|
||||
</select>
|
||||
<div class="cbi-value-description">
|
||||
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" /></span>
|
||||
<%:The speed measurement terminal must be in the same LAN as the router that starts the speed measurement%><br />
|
||||
<%:Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service%>
|
||||
</div></div></div>
|
||||
<div class="cbi-value" ><label class="cbi-value-title" ><%:Perform operation%></label>
|
||||
<div class="cbi-value-field"><input type="button" value="<%:Perform operation%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.iperf,this.form.iperf_to.selectedIndex)" />
|
||||
</div></div>
|
||||
<div class="cbi-value" >
|
||||
<label class="cbi-value-title"><%:Iperf3 speed measurement software download%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="button" class="cbi-button cbi-input-reload" value="<%:Domestic download password:%>cpd6" onclick="javascript:window.open('https://sipdboy.lanzoui.com/b01c3esih','target');" />
|
||||
<input type="button" class="cbi-button cbi-input-reload" value="<%:Download from foreign official websites%>" onclick="javascript:window.open('https://iperf.fr/iperf-download.php','target');" />
|
||||
</div></div></div>
|
||||
<fieldset class="cbi-section" style="display:none">
|
||||
<legend id="test-iperf-legend">
|
||||
<%:Collecting data...%>
|
||||
</legend>
|
||||
<span id="test-iperf-output"></span>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,27 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[network]], [[iperf3_status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('iperf3_status');
|
||||
if (data && tb)
|
||||
{
|
||||
if (data.run)
|
||||
{
|
||||
tb.innerHTML = '<br/><em style=\"color:green\"><%:The Iperf3 service is running.%></em>';
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.innerHTML = '<br/><em style=\"color:red\"><%:The Iperf3 service is not running.%></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]></script>
|
||||
|
||||
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Iperf3 Status%></legend>
|
||||
<p id="iperf3_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
@ -0,0 +1,79 @@
|
||||
<%#
|
||||
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
|
||||
https://github.com/sirpdboy/netspeedtest
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js?v=1.1"></script>
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
var stxhr = new XHR();
|
||||
function update_status(field, proto)
|
||||
{
|
||||
var tool = field.name;
|
||||
var addr = field.value;
|
||||
var protocol = proto ;
|
||||
|
||||
var legend = document.getElementById('test-iperf-legend');
|
||||
var output = document.getElementById('test-iperf-output');
|
||||
if (legend && output)
|
||||
{
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
|
||||
'<%:Waiting for command to complete...%>'
|
||||
;
|
||||
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
|
||||
stxhr.post('<%=url('admin/network')%>/test_' + tool + protocol + '/' + addr, { token: '<%=token%>' },
|
||||
function(x)
|
||||
{
|
||||
if (x.responseText)
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
|
||||
}
|
||||
else
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML ='</p> <%:Operation execution complete%></p>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<form method="post" action="<%=url('admin/network/netspeedtest')%>">
|
||||
<table>
|
||||
<tr><td class="cbi-value-title" ><input style="margin: 5px 0" type="hidden" value="" name="iperf" />
|
||||
<select name="iperf_to" style="width:auto">
|
||||
<option value="0" selected="selected"><%:iperfstart%></option>
|
||||
<option value="1"><%:iperfstop%></option>
|
||||
</select></td>
|
||||
<td class="cbi-value-field" style="width:100%;" >
|
||||
<input type="button" value="<%:Perform operation%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.iperf,this.form.iperf_to.selectedIndex)" /></td>
|
||||
</tr>
|
||||
<tr><td class="cbi-value-title" ><%:iperf3 instructions%></td>
|
||||
<td class="cbi-value-field" ><%:The speed measurement terminal must be in the same LAN as the router that starts the speed measurement%><br /><%:Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cbi-value-title"><%:Iperf3 speed measurement software download%></td>
|
||||
<td class="cbi-value-field" >
|
||||
<input type="button" class="cbi-button cbi-input-reload" value="<%:Domestic download password:%>cpd6" onclick="javascript:window.open('https://sipdboy.lanzoui.com/b01c3esih','target');" />
|
||||
<input type="button" class="cbi-button cbi-input-reload" value="<%:Download from foreign official websites%>" onclick="javascript:window.open('https://iperf.fr/iperf-download.php','target');" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<fieldset class="cbi-section" style="display:none">
|
||||
<legend id="test-iperf-legend">
|
||||
<%:Collecting data...%>
|
||||
</legend>
|
||||
<span id="test-iperf-output"></span>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,51 @@
|
||||
<%#
|
||||
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
|
||||
https://github.com/sirpdboy/netspeedtest
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<input class="cbi-button cbi-button-apply" id="update_service" type="button" onclick="run()" value="<%= translate('Perform Wan Speedtest') %>" />
|
||||
|
||||
<fieldset class="cbi-section" style="display:none">
|
||||
<legend id="wanspeedtest-legend">
|
||||
<%:Collecting data...%>
|
||||
</legend>
|
||||
<span id="wanspeedtest-output"></span>
|
||||
</fieldset>
|
||||
|
||||
<script type="text/javascript">
|
||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestrun")%>';
|
||||
function run(s) {
|
||||
var legend = document.getElementById('wanspeedtest-legend');
|
||||
var output = document.getElementById('wanspeedtest-output');
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
|
||||
'<%:Network speed test, please wait...%>'
|
||||
;
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
XHR.get(RUN_URL, null,
|
||||
|
||||
function(x)
|
||||
{
|
||||
if (x.responseText)
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML = String.format('<img src=%h height="300" style="vertical-align:middle" />', x.responseText);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML ='</p><%:Operation execution complete%></p>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
106
luci-app-netspeedtest/po/zh-cn/netspeedtest.po
Normal file
106
luci-app-netspeedtest/po/zh-cn/netspeedtest.po
Normal file
@ -0,0 +1,106 @@
|
||||
#
|
||||
# Copyright (C) 2020-2022 sirpdboy herboy2008@gmail.com https://github.com/sirpdboy/netspeedtest
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: LuCi Chinese Translation\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Language: zh_CN\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Pootle 2.0.6\n"
|
||||
|
||||
msgid "Net Speedtest"
|
||||
msgstr "网速测试"
|
||||
|
||||
msgid "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:"
|
||||
msgstr "网络速度诊断测试(包括内网、外网、特定端口服务器测速)<br/>使用说明见:"
|
||||
|
||||
msgid "Lan Speedtest Iperf3"
|
||||
msgstr "内网iperf3吞吐测速"
|
||||
|
||||
msgid "Lan homebox Web"
|
||||
msgstr "内网测速网页版"
|
||||
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "The Iperf3 service is running."
|
||||
msgstr "iperf3服务已启动"
|
||||
|
||||
msgid "The Iperf3 service is not running."
|
||||
msgstr "iperf3服务未启动"
|
||||
|
||||
msgid "Iperf3 Status"
|
||||
msgstr "iperf3服务状态"
|
||||
|
||||
msgid "The homebox service is running."
|
||||
msgstr "homebox网页测速服务已启动"
|
||||
|
||||
msgid "The homebox service is not running."
|
||||
msgstr "homebox网页测速服务未启动"
|
||||
|
||||
msgid "homebox Status"
|
||||
msgstr "homebox网页测速服务状态"
|
||||
|
||||
msgid "</br>For specific usage, see:"
|
||||
msgstr "</br>具体使用方法参见:"
|
||||
|
||||
msgid "iperfstart"
|
||||
msgstr "iperf服务启动"
|
||||
|
||||
msgid "iperfstop"
|
||||
msgstr "iperf服务停止"
|
||||
|
||||
msgid "Select function"
|
||||
msgstr "选择功能"
|
||||
|
||||
msgid "Perform operation"
|
||||
msgstr "执行操作"
|
||||
|
||||
|
||||
msgid "iperf3 instructions"
|
||||
msgstr "iperf3使用说明"
|
||||
|
||||
msgid "Test speed service started"
|
||||
msgstr "测试速度服务已经启动"
|
||||
|
||||
msgid "The speed measurement terminal must be in the same LAN as the router that starts the speed measurement"
|
||||
msgstr "测速终端机必须与启动测速的路由器在同一局域网内"
|
||||
|
||||
msgid "Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service"
|
||||
msgstr "使用步骤:A.启动路由器测速服务 B.下载测试客户端 C.运行测速客户端 D.输入路由器测速服务IP地址。 "
|
||||
|
||||
msgid "Domestic download password:"
|
||||
msgstr "国内下密码:"
|
||||
|
||||
msgid "Iperf3 speed measurement software download"
|
||||
msgstr "iperf3测速软件下载"
|
||||
|
||||
msgid "Wan Speedtest"
|
||||
msgstr "Speedtest宽带测速"
|
||||
|
||||
msgid "Perform Wan Speedtest"
|
||||
msgstr "执行Speedtest宽带测速"
|
||||
|
||||
msgid "Netperf Speedtest"
|
||||
msgstr "Netperf宽带测速"
|
||||
|
||||
msgid "Perform Netperf Speedtest"
|
||||
msgstr "执行Netperf宽带测速"
|
||||
|
||||
msgid "Operation execution complete"
|
||||
msgstr "操作执行完毕"
|
||||
|
||||
msgid "Network speed test, please wait..."
|
||||
msgstr "网速测试中,请稍侯..."
|
||||
|
||||
msgid "Download from foreign official websites"
|
||||
msgstr "国外官网"
|
||||
|
||||
msgid "Server Port Speedtest"
|
||||
msgstr "端口延迟测试"
|
||||
|
1
luci-app-netspeedtest/po/zh_Hans
Normal file
1
luci-app-netspeedtest/po/zh_Hans
Normal file
@ -0,0 +1 @@
|
||||
zh-cn
|
10
luci-app-netspeedtest/root/etc/config/netspeedtest
Normal file
10
luci-app-netspeedtest/root/etc/config/netspeedtest
Normal file
@ -0,0 +1,10 @@
|
||||
config homebox 'homebox'
|
||||
option enabled '0'
|
||||
option port '3300'
|
||||
option logger '1'
|
||||
|
||||
config speedtestiperf3 'speedtestiperf3'
|
||||
option enabled '0'
|
||||
|
||||
config wanspeedtest 'wanspeedtest'
|
||||
option surl ' '
|
80
luci-app-netspeedtest/root/etc/init.d/netspeedtest
Normal file
80
luci-app-netspeedtest/root/etc/init.d/netspeedtest
Normal file
@ -0,0 +1,80 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
#
|
||||
# Copyright (C) 2020-2023 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
|
||||
PROG=/usr/bin/homebox
|
||||
EXTRA_COMMANDS="nstest"
|
||||
|
||||
TMP_T=/var/netspeedtest.tmp
|
||||
LOCK=/var/lock/netspeedtest.lock
|
||||
LOG=/var/log/netspeedtest.log
|
||||
|
||||
limit_log() {
|
||||
local logf=$1
|
||||
[ ! -f "$logf" ] && return
|
||||
local sc=100
|
||||
[ -n "$2" ] && sc=$2
|
||||
local count=$(grep -c "" $logf)
|
||||
if [ $count -gt $sc ];then
|
||||
let count=count-$sc
|
||||
sed -i "1,$count d" $logf
|
||||
fi
|
||||
}
|
||||
|
||||
init_env() {
|
||||
[ ! -f "$LOG" ] && echo "" > $LOG
|
||||
echo 1 > $TMP_T
|
||||
|
||||
}
|
||||
|
||||
nstest() {
|
||||
[ -f $LOCK ] && exit
|
||||
limit_log $LOG 200
|
||||
init_env
|
||||
touch $LOCK
|
||||
echo -ne "\n speedtest测速" >> $LOG
|
||||
/usr/bin/speedtest --share > $TMP_T
|
||||
echo -ne "\n 测服信息:$(cat $TMP_T | grep 'Hosted by'| cut -c10- | awk -F: '{printf $1}') 延时:$(cat $TMP_T | grep 'Hosted by' | awk -F: '{printf $2}')" >> $LOG
|
||||
echo -ne "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne " ---- 上行速率:$(cat $TMP_T | grep 'Upload:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne "\n 测试时间: " >> $LOG
|
||||
echo $(date +%Y-%m-%d" "%H:%M:%S) >> $LOG
|
||||
echo -ne " ————————————————————————————\n" >> $LOG
|
||||
echo -ne $(cat $TMP_T | grep 'results:' | cut -c16- ) || echo -ne $(cat $TMP_T )
|
||||
rm -f $LOCK
|
||||
}
|
||||
|
||||
get_config() {
|
||||
config_get_bool enabled $1 enabled 1
|
||||
config_get_bool logger $1 logger 1
|
||||
}
|
||||
|
||||
homebox_prepare() {
|
||||
pgrep -f homebox | xargs kill -9 >/dev/null 2>&1
|
||||
killall homebox
|
||||
killall homebox
|
||||
}
|
||||
|
||||
start_service() {
|
||||
homebox_prepare
|
||||
config_load netspeedtest
|
||||
config_foreach get_config homebox
|
||||
[ "x$enabled" != "x1" ] && exit 1
|
||||
procd_open_instance
|
||||
procd_set_param command $PROG
|
||||
[ "x$logger" == x1 ] && procd_set_param stderr 1
|
||||
# procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "netspeedtest"
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
chmod +x /etc/init.d/netspeedtest /usr/bin/*test >/dev/null 2>&1
|
||||
|
||||
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
||||
exit 0
|
167
luci-app-netspeedtest/root/usr/bin/netperftest
Normal file
167
luci-app-netspeedtest/root/usr/bin/netperftest
Normal file
@ -0,0 +1,167 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Netperfrunner.sh - a shell script that runs several netperf commands simultaneously.
|
||||
# This mimics the stress test of Flent (www.flent.org - formerly, "netperf-wrapper")
|
||||
# from Toke <toke@toke.dk> but doesn't have the nice GUI result.
|
||||
# This can live in /usr/lib/OpenWrtScripts
|
||||
#
|
||||
# When you start this script, it concurrently uploads and downloads multiple
|
||||
# streams (files) to a server on the Internet. This places a heavy load
|
||||
# on the bottleneck link of your network (probably your connection to the
|
||||
# Internet). It also starts a ping to a well-connected host. It displays:
|
||||
#
|
||||
# a) total bandwidth available
|
||||
# b) the distribution of ping latency
|
||||
|
||||
# Usage: sh netperfrunner.sh [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -t host-to-ping ] [ -n simultaneous-streams ]
|
||||
|
||||
# Options: If options are present:
|
||||
#
|
||||
# -H | --host: DNS or Address of a netperf server (default - netperf.bufferbloat.net)
|
||||
# Alternate servers are netperf-east (east coast US), netperf-west (California),
|
||||
# and netperf-eu (Denmark)
|
||||
# -4 | -6: IPv4 or IPv6
|
||||
# -t | --time: Duration for how long each direction's test should run - (default - 60 seconds)
|
||||
# -p | --ping: Host to ping to measure latency (default - gstatic.com)
|
||||
# -n | --number: Number of simultaneous sessions (default - 5 sessions)
|
||||
|
||||
# Copyright (c) 2014-2022 - Rich Brown rich.brown@blueberryhillsoftware.com
|
||||
# GPLv2
|
||||
|
||||
# Process the ping times from the passed-in file, and summarize the results
|
||||
# grep to keep lines that have "time=", then sed to isolate the time stamps, and sort them
|
||||
# Use awk to build an array of those values, and print first & last (which are min, max)
|
||||
# and compute average.
|
||||
# If the number of samples is >= 10, also compute median, and 10th and 90th percentile readings
|
||||
|
||||
# Display the values as:
|
||||
# Latency: (in msec, 11 pings, 8.33% packet loss)
|
||||
# Min: 16.556
|
||||
# 10pct: 16.561
|
||||
# Median: 22.370
|
||||
# Avg: 21.203
|
||||
# 90pct: 23.202
|
||||
# Max: 23.394
|
||||
|
||||
# ------- Start of the main routine --------
|
||||
|
||||
# Usage: sh betterspeedtest.sh [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ]
|
||||
|
||||
# “H” and “host” DNS or IP address of the netperf server host (default: netperf.bufferbloat.net)
|
||||
# “t” and “time” Time to run the test in each direction (default: 60 seconds)
|
||||
# “p” and “ping” Host to ping for latency measurements (default: gstatic.com)
|
||||
# "n" and "number" Number of simultaneous upload or download sessions (default: 4 sessions;
|
||||
# 4 sessions chosen to match default of RRUL test)
|
||||
|
||||
# set an initial values for defaults
|
||||
TESTHOST="netperf.bufferbloat.net"
|
||||
TESTDUR="60"
|
||||
|
||||
PING4=ping
|
||||
command -v ping4 > /dev/null 2>&1 && PING4=ping4
|
||||
PING6=ping6
|
||||
|
||||
PINGHOST="netperf.bufferbloat.net"
|
||||
MAXSESSIONS=4
|
||||
TESTPROTO=-4
|
||||
|
||||
# Create temp files for netperf up/download results
|
||||
ULFILE=`mktemp /tmp/netperfUL.XXXXXX` || exit 1
|
||||
DLFILE=`mktemp /tmp/netperfDL.XXXXXX` || exit 1
|
||||
PINGFILE=`mktemp /tmp/measurepings.XXXXXX` || exit 1
|
||||
# echo $ULFILE $DLFILE $PINGFILE
|
||||
|
||||
# read the options
|
||||
|
||||
# extract options and their arguments into variables.
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-4|-6) TESTPROTO=$1; shift 1 ;;
|
||||
-H|--host)
|
||||
case "$2" in
|
||||
"") echo "Missing hostname" ; exit 1 ;;
|
||||
*) TESTHOST=$2 ; shift 2 ;;
|
||||
esac ;;
|
||||
-t|--time)
|
||||
case "$2" in
|
||||
"") echo "Missing duration" ; exit 1 ;;
|
||||
*) TESTDUR=$2 ; shift 2 ;;
|
||||
esac ;;
|
||||
-p|--ping)
|
||||
case "$2" in
|
||||
"") echo "Missing ping host" ; exit 1 ;;
|
||||
*) PINGHOST=$2 ; shift 2 ;;
|
||||
esac ;;
|
||||
-n|--number)
|
||||
case "$2" in
|
||||
"") echo "Missing number of simultaneous sessions" ; exit 1 ;;
|
||||
*) MAXSESSIONS=$2 ; shift 2 ;;
|
||||
esac ;;
|
||||
--) shift ; break ;;
|
||||
*) echo "Usage: sh Netperfrunner.sh [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-streams ]" ; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Start main test
|
||||
|
||||
if [ $TESTPROTO -eq "-4" ]
|
||||
then
|
||||
PROTO="ipv4"
|
||||
else
|
||||
PROTO="ipv6"
|
||||
fi
|
||||
DATE=`date "+%Y-%m-%d %H:%M:%S"`
|
||||
|
||||
LOG=/var/log/netspeedtest.log
|
||||
echo -ne "\n netperf测速" | tee -a $LOG
|
||||
echo -ne "\n 测服信息:$TESTHOST 协议:($PROTO) 线程:$MAXSESSIONS " | tee -a $LOG
|
||||
# Start Ping
|
||||
if [ $TESTPROTO -eq "-4" ]
|
||||
then
|
||||
"${PING4}" $PINGHOST > $PINGFILE &
|
||||
else
|
||||
"${PING6}" $PINGHOST > $PINGFILE &
|
||||
fi
|
||||
ping_pid=$!
|
||||
# echo "Ping PID: $ping_pid"
|
||||
|
||||
# Start $MAXSESSIONS upload datastreams from netperf client to the netperf server
|
||||
# netperf writes the sole output value (in Mbps) to stdout when completed
|
||||
for i in $( seq $MAXSESSIONS )
|
||||
do
|
||||
netperf $TESTPROTO -H $TESTHOST -t TCP_STREAM -l $TESTDUR -v 0 -P 0 >> $ULFILE &
|
||||
# echo "Starting upload #$i $!"
|
||||
done
|
||||
|
||||
# Start $MAXSESSIONS download datastreams from netperf server to the client
|
||||
for i in $( seq $MAXSESSIONS )
|
||||
do
|
||||
netperf $TESTPROTO -H $TESTHOST -t TCP_MAERTS -l $TESTDUR -v 0 -P 0 >> $DLFILE &
|
||||
# echo "Starting download #$i $!"
|
||||
done
|
||||
|
||||
# Wait until each of the background netperf processes completes
|
||||
# echo "Process is $$"
|
||||
# echo `pgrep -P $$ netperf `
|
||||
|
||||
for i in `pgrep -P $$ netperf` # get a list of PIDs for child processes named 'netperf'
|
||||
do
|
||||
# echo "Waiting for $i"
|
||||
wait $i
|
||||
done
|
||||
|
||||
# Stop the pings after the netperf's are all done
|
||||
kill -9 $ping_pid
|
||||
wait $ping_pid 2>/dev/null
|
||||
|
||||
echo -ne "\n 下行速率:" `awk '{s+=$1} END {print s}' $DLFILE` Mbps | tee -a $LOG
|
||||
echo -ne " ---- 上行速率:" `awk '{s+=$1} END {print s}' $ULFILE` Mbps | tee -a $LOG
|
||||
echo -ne "\n 测试时间: " | tee -a $LOG
|
||||
echo $(date +%Y-%m-%d" "%H:%M:%S) | tee -a $LOG
|
||||
echo -ne " ————————————————————————————\n" | tee -a $LOG
|
||||
|
||||
# Clean up
|
||||
rm $PINGFILE
|
||||
rm $DLFILE
|
||||
rm $ULFILE
|
2004
luci-app-netspeedtest/root/usr/bin/speedtest
Normal file
2004
luci-app-netspeedtest/root/usr/bin/speedtest
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-netspeedtest": {
|
||||
"description": "Grant UCI access for luci-app-netspeedtest",
|
||||
"read": {
|
||||
"uci": [ "netspeedtest" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "netspeedtest" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user