Developing lightweight computation at the DSG edge

Commit 5a73360d authored by p4u's avatar p4u
Browse files

Added new tab Info with some system information

parent 6b407980
......@@ -30,6 +30,7 @@ function print_help()
print("Possible questions:")
print(" modes: supported modes by the wireless card")
print(" channels: supported channels and supported HT40 type (+/-) ")
print(" ipv4: print all ipv4 from this computer (excluding localhost)")
print("")
end
......@@ -62,22 +63,30 @@ function print_txpower()
print(v)
end
end
function print_ipv4()
local ipv4 = qmp.get_ipv4()
for _,v in pairs(ipv4) do
print(v)
end
end
if #arg ~= 2 then
if #arg ~= 1 then
print_help()
os.exit(1)
end
local question = arg[1]
dev = arg[2]
dev = arg[2]
if question == "modes" then
print_modes()
elseif question == "channels" then
print_channels()
elseif question == "txpower" then
print_txpower()
elseif question == "ipv4" then
print_ipv4()
else
print_help()
end
......
......@@ -21,6 +21,8 @@
--]]
iwinfo = require "iwinfo"
util = require "luci.util"
sys = require "luci.sys"
qmpinfo = {}
......@@ -125,4 +127,26 @@ function qmpinfo.get_channels(dev)
return clist
end
function qmpinfo.get_ipv4()
local ipv4 = {}
local ipv4_raw = util.exec("ip -4 a | grep inet | awk '{print $2}' | awk -F/ '{print $1}' | grep -v 127.0.0.1")
for _,v in ipairs(util.split(ipv4_raw)) do
if #util.trim(v) > 1 then
table.insert(ipv4,util.trim(v))
end
end
return ipv4
end
function qmpinfo.get_hostname()
local hostname = util.exec("cat /proc/sys/kernel/hostname")
return hostname
end
function qmpinfo.get_uname()
local uname = util.exec("uname -a")
return uname
end
return qmpinfo
......@@ -29,17 +29,23 @@ function index()
root.index = true
-- Main window with auth enabled
overview = entry({"qmp"}, template("qmp/overview"), "qMp", 1)
overview = entry({"qmp"}, call("action_status"), "qMp", 1)
overview.dependent = false
overview.sysauth = "root"
overview.sysauth_authenticator = "htmlauth"
-- Rest of entries
entry({"qmp","info"}, call("action_status"), "Info", 1).dependent=false
entry({"qmp","network"}, cbi("qmp/config"), "Network", 5).dependent=false
entry({"qmp","wireless"}, cbi("qmp/wireless"), "Wireless", 6).dependent=false
end
function action_status()
luci.http.prepare_content("text/plain")
luci.http.write("Quick Mesh Project [qMp]")
package.path = package.path .. ";/etc/qmp/?.lua"
local qmp = require "qmpinfo"
local ipv4 = qmp.get_ipv4()
local hostname = qmp.get_hostname()
local uname = qmp.get_uname()
luci.template.render("qmp/overview",{ipv4=ipv4,hostname=hostname,uname=uname})
end
......@@ -14,4 +14,22 @@
<br />
<p>Visit our web page for more information: <a href="http://qmp.cat" target="_blank">qmp.cat</a> </p>
<h2>About this device</h2>
<p>
<strong>Hostname:</strong> <%=hostname%>
</p>
<p>
<strong>System:</strong> <%=uname%>
</p>
<p>
<strong>IPv4 addresses</strong>
<ul>
<% for i,v in ipairs(ipv4) do %>
<li><%=v%></li>
<% end %>
</ul>
</p>
<%+footer%>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment