luci-app-mwan3: refactoring troubleshooting page
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
24fe9b1279
commit
6a700eded1
2 changed files with 102 additions and 130 deletions
|
@ -198,104 +198,104 @@ end
|
||||||
|
|
||||||
function troubleshootingData()
|
function troubleshootingData()
|
||||||
local ver = require "luci.version"
|
local ver = require "luci.version"
|
||||||
|
local dash = "-------------------------------------------------"
|
||||||
|
|
||||||
local mArray = {}
|
luci.http.prepare_content("text/plain")
|
||||||
|
|
||||||
-- software versions
|
luci.http.write("\n")
|
||||||
local wrtRelease = ut.trim(ver.distversion)
|
luci.http.write("\n")
|
||||||
if wrtRelease ~= "" then
|
luci.http.write("Software-Version")
|
||||||
wrtRelease = "OpenWrt - " .. wrtRelease
|
luci.http.write("\n")
|
||||||
|
luci.http.write(dash)
|
||||||
|
luci.http.write("\n")
|
||||||
|
if ver.distversion then
|
||||||
|
luci.http.write(string.format("OpenWrt - %s", ver.distversion))
|
||||||
|
luci.http.write("\n")
|
||||||
else
|
else
|
||||||
wrtRelease = "OpenWrt - unknown"
|
luci.http.write("OpenWrt - unknown")
|
||||||
|
luci.http.write("\n")
|
||||||
end
|
end
|
||||||
local luciRelease = ut.trim(ver.luciversion)
|
|
||||||
if luciRelease ~= "" then
|
if ver.luciversion then
|
||||||
luciRelease = "\nLuCI - " .. luciRelease
|
luci.http.write(string.format("LuCI - %s", ver.luciversion))
|
||||||
|
luci.http.write("\n")
|
||||||
else
|
else
|
||||||
luciRelease = "\nLuCI - unknown"
|
luci.http.write("LuCI - unknown")
|
||||||
|
luci.http.write("\n")
|
||||||
end
|
end
|
||||||
local mwanVersion = ut.trim(sys.exec("opkg info mwan3 | grep Version | awk '{print $2}'"))
|
|
||||||
if mwanVersion ~= "" then
|
luci.http.write("\n")
|
||||||
mwanVersion = "\n\nmwan3 - " .. mwanVersion
|
luci.http.write("\n")
|
||||||
|
local output = ut.trim(sys.exec("ip a show"))
|
||||||
|
luci.http.write("Output of \"ip a show\"")
|
||||||
|
luci.http.write("\n")
|
||||||
|
luci.http.write(dash)
|
||||||
|
luci.http.write("\n")
|
||||||
|
if output ~= "" then
|
||||||
|
luci.http.write(output)
|
||||||
|
luci.http.write("\n")
|
||||||
else
|
else
|
||||||
mwanVersion = "\n\nmwan3 - unknown"
|
luci.http.write("No data found")
|
||||||
|
luci.http.write("\n")
|
||||||
end
|
end
|
||||||
local mwanLuciVersion = ut.trim(sys.exec("opkg info luci-app-mwan3 | grep Version | awk '{print $2}'"))
|
|
||||||
if mwanLuciVersion ~= "" then
|
luci.http.write("\n")
|
||||||
mwanLuciVersion = "\nmwan3-luci - " .. mwanLuciVersion
|
luci.http.write("\n")
|
||||||
|
local output = ut.trim(sys.exec("ip route show"))
|
||||||
|
luci.http.write("Output of \"ip route show\"")
|
||||||
|
luci.http.write("\n")
|
||||||
|
luci.http.write(dash)
|
||||||
|
luci.http.write("\n")
|
||||||
|
if output ~= "" then
|
||||||
|
luci.http.write(output)
|
||||||
|
luci.http.write("\n")
|
||||||
else
|
else
|
||||||
mwanLuciVersion = "\nmwan3-luci - unknown"
|
luci.http.write("No data found")
|
||||||
|
luci.http.write("\n")
|
||||||
end
|
end
|
||||||
mArray.versions = { wrtRelease .. luciRelease .. mwanVersion .. mwanLuciVersion }
|
|
||||||
|
|
||||||
-- mwan config
|
luci.http.write("\n")
|
||||||
local mwanConfig = ut.trim(sys.exec("cat /etc/config/mwan3"))
|
luci.http.write("\n")
|
||||||
if mwanConfig == "" then
|
local output = ut.trim(sys.exec("ip rule show"))
|
||||||
mwanConfig = "No data found"
|
luci.http.write("Output of \"ip rule show\"")
|
||||||
end
|
luci.http.write("\n")
|
||||||
mArray.mwanconfig = { mwanConfig }
|
luci.http.write(dash)
|
||||||
|
luci.http.write("\n")
|
||||||
-- network config
|
if output ~= "" then
|
||||||
local networkConfig = ut.trim(sys.exec("cat /etc/config/network | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/'"))
|
luci.http.write(output)
|
||||||
if networkConfig == "" then
|
luci.http.write("\n")
|
||||||
networkConfig = "No data found"
|
|
||||||
end
|
|
||||||
mArray.netconfig = { networkConfig }
|
|
||||||
|
|
||||||
-- wireless config
|
|
||||||
local wirelessConfig = ut.trim(sys.exec("cat /etc/config/wireless | sed -e 's/.*username.*/ USERNAME HIDDEN/' -e 's/.*password.*/ PASSWORD HIDDEN/' -e 's/.*key.*/ KEY HIDDEN/'"))
|
|
||||||
if wirelessConfig == "" then
|
|
||||||
wirelessConfig = "No data found"
|
|
||||||
end
|
|
||||||
mArray.wificonfig = { wirelessConfig }
|
|
||||||
|
|
||||||
-- ifconfig
|
|
||||||
local ifconfig = ut.trim(sys.exec("ifconfig"))
|
|
||||||
if ifconfig == "" then
|
|
||||||
ifconfig = "No data found"
|
|
||||||
end
|
|
||||||
mArray.ifconfig = { ifconfig }
|
|
||||||
|
|
||||||
-- route -n
|
|
||||||
local routeShow = ut.trim(sys.exec("route -n"))
|
|
||||||
if routeShow == "" then
|
|
||||||
routeShow = "No data found"
|
|
||||||
end
|
|
||||||
mArray.routeshow = { routeShow }
|
|
||||||
|
|
||||||
-- ip rule show
|
|
||||||
local ipRuleShow = ut.trim(sys.exec(ip .. "rule show"))
|
|
||||||
if ipRuleShow == "" then
|
|
||||||
ipRuleShow = "No data found"
|
|
||||||
end
|
|
||||||
mArray.iprule = { ipRuleShow }
|
|
||||||
|
|
||||||
-- ip route list table 1-250
|
|
||||||
local routeList, routeString = ut.trim(sys.exec(ip .. "rule | sed 's/://g' 2>/dev/null | awk '$1>=2001 && $1<=2250' | awk '{print $NF}'")), ""
|
|
||||||
if routeList ~= "" then
|
|
||||||
for line in routeList:gmatch("[^\r\n]+") do
|
|
||||||
routeString = routeString .. line .. "\n" .. sys.exec(ip .. "route list table " .. line)
|
|
||||||
end
|
|
||||||
routeString = ut.trim(routeString)
|
|
||||||
else
|
else
|
||||||
routeString = "No data found"
|
luci.http.write("No data found")
|
||||||
|
luci.http.write("\n")
|
||||||
end
|
end
|
||||||
mArray.routelist = { routeString }
|
|
||||||
|
|
||||||
-- default firewall output policy
|
luci.http.write("\n")
|
||||||
local firewallOut = ut.trim(sys.exec("uci -q -p /var/state get firewall.@defaults[0].output"))
|
luci.http.write("\n")
|
||||||
if firewallOut == "" then
|
luci.http.write("Output of \"ip route list table 1-250\"")
|
||||||
firewallOut = "No data found"
|
luci.http.write("\n")
|
||||||
|
luci.http.write(dash)
|
||||||
|
luci.http.write("\n")
|
||||||
|
for i=1,250 do
|
||||||
|
local output = ut.trim(sys.exec(string.format("ip route list table %d", i)))
|
||||||
|
if output ~= "" then
|
||||||
|
luci.http.write(string.format("Table %s: ", i))
|
||||||
|
luci.http.write(output)
|
||||||
|
luci.http.write("\n")
|
||||||
end
|
end
|
||||||
mArray.firewallout = { firewallOut }
|
|
||||||
|
|
||||||
-- iptables
|
|
||||||
local iptables = ut.trim(sys.exec("iptables -L -t mangle -v -n"))
|
|
||||||
if iptables == "" then
|
|
||||||
iptables = "No data found"
|
|
||||||
end
|
end
|
||||||
mArray.iptables = { iptables }
|
|
||||||
|
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.write("\n")
|
||||||
luci.http.write_json(mArray)
|
luci.http.write("\n")
|
||||||
|
local output = ut.trim(sys.exec("iptables -L -t mangle -v -n"))
|
||||||
|
luci.http.write("Output of \"iptables -L -t mangle -v -n\"")
|
||||||
|
luci.http.write("\n")
|
||||||
|
luci.http.write(dash)
|
||||||
|
luci.http.write("\n")
|
||||||
|
if output ~= "" then
|
||||||
|
luci.http.write(output)
|
||||||
|
luci.http.write("\n")
|
||||||
|
else
|
||||||
|
luci.http.write("No data found")
|
||||||
|
luci.http.write("\n")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,52 +10,24 @@
|
||||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "troubleshooting_display")%>', null,
|
XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "troubleshooting_display")%>', null,
|
||||||
function(x, mArray)
|
function(x)
|
||||||
{
|
{
|
||||||
var tshoot = document.getElementById('troubleshoot_text');
|
var legend = document.getElementById('diag-rc-legend');
|
||||||
if (mArray.versions)
|
var output = document.getElementById('diag-rc-output');
|
||||||
{
|
legend.style.display = 'none';
|
||||||
var versions = '<span class="description">Software versions : </span><br /><br />';
|
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
|
||||||
var mwanConfig = '<br /><br /><span class="description">Output of "cat /etc/config/mwan3" : </span><br /><br />';
|
|
||||||
var netConfig = '<br /><br /><span class="description">Output of "cat /etc/config/network" : </span><br /><br />';
|
|
||||||
var wifiConfig = '<br /><br /><span class="description">Output of "cat /etc/config/wireless" : </span><br /><br />';
|
|
||||||
var ifconfig = '<br /><br /><span class="description">Output of "ifconfig" : </span><br /><br />';
|
|
||||||
var ipRoute = '<br /><br /><span class="description">Output of "route -n" : </span><br /><br />';
|
|
||||||
var ipRuleShow = '<br /><br /><span class="description">Output of "ip rule show" : </span><br /><br />';
|
|
||||||
var routeListTable = '<br /><br /><span class="description">Output of "ip route list table 1-250" : </span><br /><br />';
|
|
||||||
var firewallOut = '<br /><br /><span class="description">Firewall default output policy (must be ACCEPT) : </span><br /><br />';
|
|
||||||
var iptables = '<br /><br /><span class="description">Output of "iptables -L -t mangle -v -n" : </span><br /><br />';
|
|
||||||
tshoot.innerHTML = String.format(
|
|
||||||
'<pre>%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s</pre>',
|
|
||||||
versions, mArray.versions[0], mwanConfig, mArray.mwanconfig[0], netConfig, mArray.netconfig[0],
|
|
||||||
wifiConfig, mArray.wificonfig[0], ifconfig, mArray.ifconfig[0], ipRoute, mArray.routeshow[0],
|
|
||||||
ipRuleShow, mArray.iprule[0], routeListTable, mArray.routelist[0], firewallOut, mArray.firewallout[0],
|
|
||||||
iptables, mArray.iptables[0]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tshoot.innerHTML = '<strong><%:Error collecting troubleshooting information%></strong>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
//]]></script>
|
//]]></script>
|
||||||
|
|
||||||
<div id="troubleshoot">
|
<div class="cbi-map">
|
||||||
|
<h2 name="content"><%:MWAN Status - Troubleshooting%></h2>
|
||||||
<fieldset class="cbi-section">
|
<fieldset class="cbi-section">
|
||||||
<legend><%:Troubleshooting Data%></legend>
|
<legend id="diag-rc-legend"><%:Collecting data...%></legend>
|
||||||
<div id="troubleshoot_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%></div>
|
<span id="diag-rc-output">
|
||||||
|
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align: middle;" />
|
||||||
|
</span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
#troubleshoot_text {
|
|
||||||
padding: 20px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.description {
|
|
||||||
background-color: rgb(78, 186, 241);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<%+footer%>
|
<%+footer%>
|
||||||
|
|
Loading…
Reference in a new issue