2015-01-16 22:38:38 +00:00
|
|
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
|
|
|
-- Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
|
|
|
|
-- Licensed to the public under the Apache License 2.0.
|
2011-08-12 13:16:27 +00:00
|
|
|
|
2008-05-25 17:00:30 +00:00
|
|
|
module("luci.controller.admin.status", package.seeall)
|
2008-05-13 17:32:11 +00:00
|
|
|
|
2008-05-22 14:04:03 +00:00
|
|
|
function index()
|
2011-08-12 13:16:27 +00:00
|
|
|
entry({"admin", "status"}, alias("admin", "status", "overview"), _("Status"), 20).index = true
|
|
|
|
entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1)
|
|
|
|
entry({"admin", "status", "iptables"}, call("action_iptables"), _("Firewall"), 2).leaf = true
|
|
|
|
entry({"admin", "status", "routes"}, template("admin_status/routes"), _("Routes"), 3)
|
|
|
|
entry({"admin", "status", "syslog"}, call("action_syslog"), _("System Log"), 4)
|
|
|
|
entry({"admin", "status", "dmesg"}, call("action_dmesg"), _("Kernel Log"), 5)
|
2011-10-15 05:10:58 +00:00
|
|
|
entry({"admin", "status", "processes"}, cbi("admin_status/processes"), _("Processes"), 6)
|
2011-08-12 13:16:27 +00:00
|
|
|
|
2011-10-15 05:10:58 +00:00
|
|
|
entry({"admin", "status", "realtime"}, alias("admin", "status", "realtime", "load"), _("Realtime Graphs"), 7)
|
2010-11-28 14:40:43 +00:00
|
|
|
|
2011-10-15 05:10:58 +00:00
|
|
|
entry({"admin", "status", "realtime", "load"}, template("admin_status/load"), _("Load"), 1).leaf = true
|
|
|
|
entry({"admin", "status", "realtime", "load_status"}, call("action_load")).leaf = true
|
2010-11-28 06:41:45 +00:00
|
|
|
|
2011-10-15 05:10:58 +00:00
|
|
|
entry({"admin", "status", "realtime", "bandwidth"}, template("admin_status/bandwidth"), _("Traffic"), 2).leaf = true
|
|
|
|
entry({"admin", "status", "realtime", "bandwidth_status"}, call("action_bandwidth")).leaf = true
|
2011-09-13 07:27:34 +00:00
|
|
|
|
2011-10-15 05:10:58 +00:00
|
|
|
entry({"admin", "status", "realtime", "wireless"}, template("admin_status/wireless"), _("Wireless"), 3).leaf = true
|
|
|
|
entry({"admin", "status", "realtime", "wireless_status"}, call("action_wireless")).leaf = true
|
2011-05-04 21:23:55 +00:00
|
|
|
|
2011-10-15 05:10:58 +00:00
|
|
|
entry({"admin", "status", "realtime", "connections"}, template("admin_status/connections"), _("Connections"), 4).leaf = true
|
|
|
|
entry({"admin", "status", "realtime", "connections_status"}, call("action_connections")).leaf = true
|
2012-03-04 18:36:05 +00:00
|
|
|
|
|
|
|
entry({"admin", "status", "nameinfo"}, call("action_nameinfo")).leaf = true
|
2008-05-22 14:04:03 +00:00
|
|
|
end
|
|
|
|
|
2008-05-13 17:32:11 +00:00
|
|
|
function action_syslog()
|
2008-05-25 17:00:30 +00:00
|
|
|
local syslog = luci.sys.syslog()
|
|
|
|
luci.template.render("admin_status/syslog", {syslog=syslog})
|
2008-11-16 22:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function action_dmesg()
|
|
|
|
local dmesg = luci.sys.dmesg()
|
|
|
|
luci.template.render("admin_status/dmesg", {dmesg=dmesg})
|
|
|
|
end
|
2009-02-08 03:56:50 +00:00
|
|
|
|
|
|
|
function action_iptables()
|
2011-01-29 22:50:13 +00:00
|
|
|
if luci.http.formvalue("zero") then
|
|
|
|
if luci.http.formvalue("zero") == "6" then
|
|
|
|
luci.util.exec("ip6tables -Z")
|
|
|
|
else
|
|
|
|
luci.util.exec("iptables -Z")
|
|
|
|
end
|
2009-02-08 03:56:50 +00:00
|
|
|
luci.http.redirect(
|
|
|
|
luci.dispatcher.build_url("admin", "status", "iptables")
|
|
|
|
)
|
|
|
|
elseif luci.http.formvalue("restart") == "1" then
|
2013-03-07 12:17:43 +00:00
|
|
|
luci.util.exec("/etc/init.d/firewall reload")
|
2009-02-08 03:56:50 +00:00
|
|
|
luci.http.redirect(
|
|
|
|
luci.dispatcher.build_url("admin", "status", "iptables")
|
|
|
|
)
|
|
|
|
else
|
|
|
|
luci.template.render("admin_status/iptables")
|
|
|
|
end
|
|
|
|
end
|
2010-11-28 06:41:45 +00:00
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function action_bandwidth(iface)
|
2011-09-01 22:54:29 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
|
|
|
|
local bwc = io.popen("luci-bwc -i %q 2>/dev/null" % iface)
|
|
|
|
if bwc then
|
|
|
|
luci.http.write("[")
|
|
|
|
|
|
|
|
while true do
|
|
|
|
local ln = bwc:read("*l")
|
|
|
|
if not ln then break end
|
|
|
|
luci.http.write(ln)
|
2010-11-28 14:40:43 +00:00
|
|
|
end
|
|
|
|
|
2011-09-01 22:54:29 +00:00
|
|
|
luci.http.write("]")
|
|
|
|
bwc:close()
|
2010-11-28 14:40:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-21 19:29:47 +00:00
|
|
|
function action_wireless(iface)
|
2011-09-13 07:27:34 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
|
|
|
|
local bwc = io.popen("luci-bwc -r %q 2>/dev/null" % iface)
|
|
|
|
if bwc then
|
|
|
|
luci.http.write("[")
|
|
|
|
|
|
|
|
while true do
|
|
|
|
local ln = bwc:read("*l")
|
|
|
|
if not ln then break end
|
|
|
|
luci.http.write(ln)
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.write("]")
|
|
|
|
bwc:close()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-11-28 14:40:43 +00:00
|
|
|
function action_load()
|
2011-09-01 22:54:29 +00:00
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
|
|
|
|
local bwc = io.popen("luci-bwc -l 2>/dev/null")
|
|
|
|
if bwc then
|
|
|
|
luci.http.write("[")
|
|
|
|
|
|
|
|
while true do
|
|
|
|
local ln = bwc:read("*l")
|
|
|
|
if not ln then break end
|
|
|
|
luci.http.write(ln)
|
2010-11-28 06:41:45 +00:00
|
|
|
end
|
|
|
|
|
2011-09-01 22:54:29 +00:00
|
|
|
luci.http.write("]")
|
|
|
|
bwc:close()
|
2010-11-28 06:41:45 +00:00
|
|
|
end
|
|
|
|
end
|
2010-11-28 18:01:07 +00:00
|
|
|
|
|
|
|
function action_connections()
|
2011-03-13 22:12:42 +00:00
|
|
|
local sys = require "luci.sys"
|
|
|
|
|
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
|
|
|
|
luci.http.write("{ connections: ")
|
|
|
|
luci.http.write_json(sys.net.conntrack())
|
2010-11-28 18:01:07 +00:00
|
|
|
|
2011-09-01 22:54:29 +00:00
|
|
|
local bwc = io.popen("luci-bwc -c 2>/dev/null")
|
|
|
|
if bwc then
|
|
|
|
luci.http.write(", statistics: [")
|
2010-11-28 18:01:07 +00:00
|
|
|
|
2011-09-01 22:54:29 +00:00
|
|
|
while true do
|
|
|
|
local ln = bwc:read("*l")
|
|
|
|
if not ln then break end
|
|
|
|
luci.http.write(ln)
|
2010-11-28 18:01:07 +00:00
|
|
|
end
|
2011-09-01 22:54:29 +00:00
|
|
|
|
|
|
|
luci.http.write("]")
|
|
|
|
bwc:close()
|
2010-11-28 18:01:07 +00:00
|
|
|
end
|
|
|
|
|
2011-03-13 22:12:42 +00:00
|
|
|
luci.http.write(" }")
|
2010-11-28 18:01:07 +00:00
|
|
|
end
|
2012-03-04 18:36:05 +00:00
|
|
|
|
|
|
|
function action_nameinfo(...)
|
|
|
|
local i
|
|
|
|
local rv = { }
|
|
|
|
for i = 1, select('#', ...) do
|
|
|
|
local addr = select(i, ...)
|
|
|
|
local fqdn = nixio.getnameinfo(addr)
|
|
|
|
rv[addr] = fqdn or (addr:match(":") and "[%s]" % addr or addr)
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
luci.http.write_json(rv)
|
|
|
|
end
|