update 2023-01-14 20:16:49
This commit is contained in:
parent
67d7ee58c7
commit
fd0fffdafe
|
@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk
|
||||||
PKG_NAME:=luci-app-netspeedtest
|
PKG_NAME:=luci-app-netspeedtest
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for netspeedtest
|
LUCI_TITLE:=LuCI Support for netspeedtest
|
||||||
LUCI_DEPENDS:=+python3 +iperf3 +speedtest-web
|
LUCI_DEPENDS:=+python3 +iperf3 +homebox +netperf
|
||||||
LUCI_PKGARCH:=all
|
LUCI_PKGARCH:=all
|
||||||
PKG_VERSION:=2.0.4
|
PKG_VERSION:=2.0.6
|
||||||
PKG_RELEASE:=20221023
|
PKG_RELEASE:=20230113
|
||||||
PKG_MAINTAINER:=<https://github.com/sirpdboy/netspeedtest>
|
PKG_MAINTAINER:=<https://github.com/sirpdboy/netspeedtest>
|
||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
|
@ -2,36 +2,41 @@
|
||||||
|
|
||||||
module("luci.controller.netspeedtest", package.seeall)
|
module("luci.controller.netspeedtest", package.seeall)
|
||||||
local fs=require"nixio.fs"
|
local fs=require"nixio.fs"
|
||||||
|
local sys = require "luci.sys"
|
||||||
function index()
|
function index()
|
||||||
entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "speedtestweb"),_("Net Speedtest"), 90).dependent = true
|
entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "homebox"),_("Net Speedtest"), 90).dependent = true
|
||||||
entry({"admin","network","netspeedtest","speedtestweb"},cbi("netspeedtest/speedtestweb"),_("Lan Speedtest Web"),20).leaf = 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","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","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", "netspeedtest", "checknet"}, call("check_net"))
|
||||||
|
entry({"admin", "network", "homebox_status"}, call("homebox_status"))
|
||||||
entry({"admin", "network", "speedtestweb_status"}, call("speedtestweb_status"))
|
|
||||||
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
|
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
|
||||||
|
|
||||||
entry({"admin", "network","test_iperf0"}, post("test_iperf0"), nil).leaf = true
|
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","test_iperf1"}, post("test_iperf1"), nil).leaf = true
|
||||||
|
|
||||||
--entry({"admin","network","netspeedtest", "wanrun"}, post("wanrun"), nil).leaf = true
|
entry({"admin","network","netspeedtest", "speedtestrun"}, call("speedtestrun"))
|
||||||
entry({"admin","network","netspeedtest", "wanrun"}, call("wanrun"))
|
entry({"admin","network","netspeedtest", "netperfrun"}, call("netperfrun"))
|
||||||
|
|
||||||
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
|
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
|
||||||
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
|
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function speedtestweb_status()
|
|
||||||
local e={}
|
function homebox_status()
|
||||||
e.run=luci.sys.call("pgrep speedtest-web >/dev/null")==0
|
local e = {
|
||||||
|
run = (sys.call("pidof homebox >/dev/null") == 0),
|
||||||
|
port = 3300
|
||||||
|
}
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(e)
|
luci.http.write_json(e)
|
||||||
end
|
end
|
||||||
|
|
||||||
function iperf3_status()
|
function iperf3_status()
|
||||||
local e={}
|
local e={}
|
||||||
e.run=luci.sys.call("pgrep iperf3 >/dev/null")==0
|
e.run=sys.call("pgrep iperf3 >/dev/null")==0
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(e)
|
luci.http.write_json(e)
|
||||||
end
|
end
|
||||||
|
@ -52,21 +57,21 @@ function testout(cmd, addr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_iperf0(addr)
|
function test_iperf0(addr)
|
||||||
luci.sys.call("pgrep -f unblockneteasemusic | xargs kill -9 >/dev/null 2>&1 ")
|
sys.call("pgrep -f unblockneteasemusic | xargs kill -9 >/dev/null 2>&1 ")
|
||||||
luci.sys.call("/etc/init.d/unblockneteasemusic stop ")
|
sys.call("/etc/init.d/unblockneteasemusic stop ")
|
||||||
luci.sys.call("/etc/init.d/unblockmusic stop ")
|
sys.call("/etc/init.d/unblockmusic stop ")
|
||||||
testout("iperf3 -s ", addr)
|
testout("iperf3 -s ", addr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_iperf1(addr)
|
function test_iperf1(addr)
|
||||||
luci.sys.call("pgrep -f iperf3 | xargs kill -9 >/dev/null 2>&1 ")
|
sys.call("pgrep -f iperf3 | xargs kill -9 >/dev/null 2>&1 ")
|
||||||
luci.sys.call("/etc/init.d/unblockneteasemusic restart")
|
sys.call("/etc/init.d/unblockneteasemusic restart")
|
||||||
luci.sys.call("/etc/init.d/unblockmusic restart")
|
sys.call("/etc/init.d/unblockmusic restart")
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_log()
|
function get_log()
|
||||||
local e = {}
|
local e = {}
|
||||||
e.running = luci.sys.call("busybox ps -w | grep netspeedtest | grep -v grep >/dev/null") == 0
|
e.running = sys.call("busybox ps -w | grep netspeedtest | grep -v grep >/dev/null") == 0
|
||||||
e.log = fs.readfile("/var/log/netspeedtest.log") or ""
|
e.log = fs.readfile("/var/log/netspeedtest.log") or ""
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(e)
|
luci.http.write_json(e)
|
||||||
|
@ -78,7 +83,10 @@ function dellog()
|
||||||
http.write('')
|
http.write('')
|
||||||
end
|
end
|
||||||
|
|
||||||
function wanrun()
|
function speedtestrun()
|
||||||
testout("/etc/init.d/netspeedtest nstest ")
|
testout("/etc/init.d/netspeedtest nstest ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function netperfrun()
|
||||||
|
testout("sh /usr/bin/netperftest")
|
||||||
|
end
|
||||||
|
|
|
@ -4,9 +4,9 @@ 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 = 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/speedtestweb_status"
|
-- m:section(SimpleSection).template = "netspeedtest/homebox_status"
|
||||||
|
|
||||||
s = m:section(TypedSection, "speedtestweb", translate('Lan Speedtest Web'))
|
s = m:section(TypedSection, "homebox", translate('Lan homebox Web'))
|
||||||
s.addremove=false
|
s.addremove=false
|
||||||
s.anonymous=true
|
s.anonymous=true
|
||||||
|
|
||||||
|
@ -15,10 +15,11 @@ o.default=0
|
||||||
|
|
||||||
o = s:option(DummyValue, '', '')
|
o = s:option(DummyValue, '', '')
|
||||||
o.rawhtml = true
|
o.rawhtml = true
|
||||||
o.template ='netspeedtest/speedtestweb'
|
o.template ='netspeedtest/homebox'
|
||||||
|
|
||||||
local o=luci.http.formvalue("cbi.apply")
|
m.apply_on_parse = true
|
||||||
if o then
|
m.on_after_apply = function(self,map)
|
||||||
io.popen("/etc/init.d/netspeedtest start")
|
io.popen("/etc/init.d/netspeedtest start")
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
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 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>
|
|
@ -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%>
|
|
@ -14,7 +14,6 @@
|
||||||
var tool = field.name;
|
var tool = field.name;
|
||||||
var addr = field.value;
|
var addr = field.value;
|
||||||
var protocol = proto ;
|
var protocol = proto ;
|
||||||
|
|
||||||
var legend = document.getElementById('test-iperf-legend');
|
var legend = document.getElementById('test-iperf-legend');
|
||||||
var output = document.getElementById('test-iperf-output');
|
var output = document.getElementById('test-iperf-output');
|
||||||
if (legend && output)
|
if (legend && output)
|
||||||
|
@ -39,9 +38,7 @@
|
||||||
{
|
{
|
||||||
legend.style.display = 'none';
|
legend.style.display = 'none';
|
||||||
output.innerHTML ='</p> <%:Operation execution complete%></p>';
|
output.innerHTML ='</p> <%:Operation execution complete%></p>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
-%>
|
-%>
|
||||||
<%+cbi/valueheader%>
|
<%+cbi/valueheader%>
|
||||||
|
|
||||||
<input class="cbi-button cbi-button-apply" id="update_service" type="button" onclick="run()" value="<%= translate('Perform WanSpeedtest') %>" />
|
<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">
|
<fieldset class="cbi-section" style="display:none">
|
||||||
<legend id="wanspeedtest-legend">
|
<legend id="wanspeedtest-legend">
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","wanrun")%>';
|
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestrun")%>';
|
||||||
function run(s) {
|
function run(s) {
|
||||||
var legend = document.getElementById('wanspeedtest-legend');
|
var legend = document.getElementById('wanspeedtest-legend');
|
||||||
var output = document.getElementById('wanspeedtest-output');
|
var output = document.getElementById('wanspeedtest-output');
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<%#
|
|
||||||
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="speedtest-web" style="width: 90%; min-height: 500px; border: none; border-radius: 3px;"></iframe>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
document.getElementById("speedtest-web").src = window.location.protocol + "//" + window.location.hostname + ":8989";
|
|
||||||
document.getElementById("speedtest-web").height = document.documentElement.clientHeight;
|
|
||||||
window.onresize = function(){
|
|
||||||
document.getElementById("speedtest-web").height = document.documentElement.clientHeight;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<%+cbi/valuefooter%>
|
|
|
@ -1,28 +0,0 @@
|
||||||
<script type="text/javascript">//<![CDATA[
|
|
||||||
XHR.poll(3, '<%=url([[admin]], [[network]], [[speedtestweb_status]])%>', null,
|
|
||||||
function(x, data) {
|
|
||||||
var tb = document.getElementById('speedtestweb_status');
|
|
||||||
if (data && tb)
|
|
||||||
{
|
|
||||||
if (data.run)
|
|
||||||
{
|
|
||||||
tb.innerHTML = '<br/><em style=\"color:green\"><%:The Speedtestweb service is running.%></em>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tb.innerHTML = '<br/><em style=\"color:red\"><%:The Speedtestweb service is not running.%></em>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
//]]></script>
|
|
||||||
|
|
||||||
|
|
||||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
|
||||||
<fieldset class="cbi-section">
|
|
||||||
<legend><%:Speedtestweb Status%></legend>
|
|
||||||
<p id="speedtestweb_status">
|
|
||||||
<em><%:Collecting data...%></em>
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
|
@ -22,7 +22,7 @@ msgstr "网络速度诊断测试(包括内网、外网、特定端口服务器
|
||||||
msgid "Lan Speedtest Iperf3"
|
msgid "Lan Speedtest Iperf3"
|
||||||
msgstr "内网iperf3吞吐测速"
|
msgstr "内网iperf3吞吐测速"
|
||||||
|
|
||||||
msgid "Lan Speedtest Web"
|
msgid "Lan homebox Web"
|
||||||
msgstr "内网测速网页版"
|
msgstr "内网测速网页版"
|
||||||
|
|
||||||
msgid "Running state"
|
msgid "Running state"
|
||||||
|
@ -37,14 +37,14 @@ msgstr "iperf3服务未启动"
|
||||||
msgid "Iperf3 Status"
|
msgid "Iperf3 Status"
|
||||||
msgstr "iperf3服务状态"
|
msgstr "iperf3服务状态"
|
||||||
|
|
||||||
msgid "The Speedtestweb service is running."
|
msgid "The homebox service is running."
|
||||||
msgstr "网页测速服务已启动"
|
msgstr "homebox网页测速服务已启动"
|
||||||
|
|
||||||
msgid "The Speedtestweb service is not running."
|
msgid "The homebox service is not running."
|
||||||
msgstr "网页测速服务未启动"
|
msgstr "homebox网页测速服务未启动"
|
||||||
|
|
||||||
msgid "Speedtestweb Status"
|
msgid "homebox Status"
|
||||||
msgstr "网页测速服务状态"
|
msgstr "homebox网页测速服务状态"
|
||||||
|
|
||||||
msgid "</br>For specific usage, see:"
|
msgid "</br>For specific usage, see:"
|
||||||
msgstr "</br>具体使用方法参见:"
|
msgstr "</br>具体使用方法参见:"
|
||||||
|
@ -77,10 +77,16 @@ msgid "Iperf3 speed measurement software download"
|
||||||
msgstr "iperf3测速软件下载"
|
msgstr "iperf3测速软件下载"
|
||||||
|
|
||||||
msgid "Wan Speedtest"
|
msgid "Wan Speedtest"
|
||||||
msgstr "宽带速率测试"
|
msgstr "Speedtest宽带测速"
|
||||||
|
|
||||||
msgid "Perform WanSpeedtest"
|
msgid "Perform Wan Speedtest"
|
||||||
msgstr "执行宽带测速"
|
msgstr "执行Speedtest宽带测速"
|
||||||
|
|
||||||
|
msgid "Netperf Speedtest"
|
||||||
|
msgstr "Netperf宽带测速"
|
||||||
|
|
||||||
|
msgid "Perform Netperf Speedtest"
|
||||||
|
msgstr "执行Netperf宽带测速"
|
||||||
|
|
||||||
msgid "Operation execution complete"
|
msgid "Operation execution complete"
|
||||||
msgstr "操作执行完毕"
|
msgstr "操作执行完毕"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
config speedtestweb 'speedtestweb'
|
config homebox 'homebox'
|
||||||
option enabled '1'
|
option enabled '0'
|
||||||
option port '8989'
|
option port '3300'
|
||||||
option logger '1'
|
option logger '1'
|
||||||
|
|
||||||
config speedtestiperf3 'speedtestiperf3'
|
config speedtestiperf3 'speedtestiperf3'
|
||||||
|
|
|
@ -10,7 +10,7 @@ START=99
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
|
|
||||||
PROG=/usr/bin/speedtest-web
|
PROG=/usr/bin/homebox
|
||||||
EXTRA_COMMANDS="nstest"
|
EXTRA_COMMANDS="nstest"
|
||||||
|
|
||||||
TMP_T=/var/netspeedtest.tmp
|
TMP_T=/var/netspeedtest.tmp
|
||||||
|
@ -32,7 +32,7 @@ limit_log() {
|
||||||
init_env() {
|
init_env() {
|
||||||
[ ! -f "$LOG" ] && echo "" > $LOG
|
[ ! -f "$LOG" ] && echo "" > $LOG
|
||||||
echo 1 > $TMP_T
|
echo 1 > $TMP_T
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nstest() {
|
nstest() {
|
||||||
|
@ -40,6 +40,8 @@ nstest() {
|
||||||
limit_log $LOG 200
|
limit_log $LOG 200
|
||||||
init_env
|
init_env
|
||||||
touch $LOCK
|
touch $LOCK
|
||||||
|
|
||||||
|
echo -ne "\n speedtest测速" | tee -a $LOG
|
||||||
/usr/bin/speedtest --share > $TMP_T
|
/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 '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 "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' )" >> $LOG
|
||||||
|
@ -54,28 +56,23 @@ nstest() {
|
||||||
get_config() {
|
get_config() {
|
||||||
config_get_bool enabled $1 enabled 1
|
config_get_bool enabled $1 enabled 1
|
||||||
config_get_bool logger $1 logger 1
|
config_get_bool logger $1 logger 1
|
||||||
config_get port $1 port 8989
|
|
||||||
}
|
}
|
||||||
|
|
||||||
speedtestweb_prepare() {
|
homebox_prepare() {
|
||||||
pgrep -f speedtest-web | xargs kill -9 >/dev/null 2>&1
|
pgrep -f homebox | xargs kill -9 >/dev/null 2>&1
|
||||||
logger -t netspeedtest -p warn "Netspeedtest speedtest-web is stop."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_service() {
|
stop_service() {
|
||||||
speedtestweb_prepare
|
homebox_prepare
|
||||||
echo "Netspeedtest speedtest-web is stop."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
speedtestweb_prepare
|
homebox_prepare
|
||||||
config_load netspeedtest
|
config_load netspeedtest
|
||||||
config_foreach get_config speedtestweb
|
config_foreach get_config homebox
|
||||||
[ x$enabled == x1 ] || return 1
|
[ "x$enabled" != "x1" ] && exit 1
|
||||||
logger -t netspeedtest -p warn "Netspeedtest speedtest-web is start."
|
|
||||||
echo "Netspeedtest speedtest-web is start."
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param command $PROG --listen_port "${port}"
|
procd_set_param command $PROG
|
||||||
[ "x$logger" == x1 ] && procd_set_param stderr 1
|
[ "x$logger" == x1 ] && procd_set_param stderr 1
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
chmod +x /etc/init.d/netspeedtest /usr/bin/speedtest >/dev/null 2>&1
|
chmod +x /etc/init.d/netspeedtest /usr/bin/*test >/dev/null 2>&1
|
||||||
|
|
||||||
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue