2015-01-16 22:38:38 +00:00
|
|
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
2015-01-16 22:46:42 +00:00
|
|
|
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
2015-01-16 22:38:38 +00:00
|
|
|
-- 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()
|
2019-10-31 17:49:23 +00:00
|
|
|
local page
|
|
|
|
|
2011-08-12 13:16:27 +00:00
|
|
|
entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1)
|
2015-10-20 20:27:39 +00:00
|
|
|
|
|
|
|
entry({"admin", "status", "iptables"}, template("admin_status/iptables"), _("Firewall"), 2).leaf = true
|
2018-10-10 11:11:01 +00:00
|
|
|
entry({"admin", "status", "iptables_dump"}, call("dump_iptables")).leaf = true
|
2015-10-20 20:27:39 +00:00
|
|
|
entry({"admin", "status", "iptables_action"}, post("action_iptables")).leaf = true
|
|
|
|
|
2011-08-12 13:16:27 +00:00
|
|
|
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)
|
2018-04-06 10:10:16 +00:00
|
|
|
entry({"admin", "status", "processes"}, form("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
|
|
|
|
2019-11-02 21:55:59 +00:00
|
|
|
entry({"admin", "status", "realtime", "load"}, view("status/load"), _("Load"), 1)
|
|
|
|
entry({"admin", "status", "realtime", "bandwidth"}, view("status/bandwidth"), _("Traffic"), 2)
|
|
|
|
entry({"admin", "status", "realtime", "wireless"}, view("status/wireless"), _("Wireless"), 3).uci_depends = { wireless = true }
|
|
|
|
entry({"admin", "status", "realtime", "connections"}, view("status/connections"), _("Connections"), 4)
|
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
|
|
|
|
2018-10-10 11:11:01 +00:00
|
|
|
function dump_iptables(family, table)
|
|
|
|
local prefix = (family == "6") and "ip6" or "ip"
|
|
|
|
local ok, lines = pcall(io.lines, "/proc/net/%s_tables_names" % prefix)
|
|
|
|
if ok and lines then
|
|
|
|
local s
|
|
|
|
for s in lines do
|
|
|
|
if s == table then
|
2018-12-02 19:15:34 +00:00
|
|
|
luci.http.prepare_content("text/plain")
|
|
|
|
luci.sys.process.exec({
|
|
|
|
"/usr/sbin/%stables" % prefix, "-w", "-t", table,
|
|
|
|
"--line-numbers", "-nxvL"
|
|
|
|
}, luci.http.write)
|
|
|
|
return
|
2018-10-10 11:11:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.status(404, "No such table")
|
|
|
|
luci.http.prepare_content("text/plain")
|
|
|
|
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
|
2015-10-20 20:27:39 +00:00
|
|
|
if luci.http.formvalue("family") == "6" then
|
|
|
|
luci.util.exec("/usr/sbin/ip6tables -Z")
|
2011-01-29 22:50:13 +00:00
|
|
|
else
|
2015-10-20 20:27:39 +00:00
|
|
|
luci.util.exec("/usr/sbin/iptables -Z")
|
2011-01-29 22:50:13 +00:00
|
|
|
end
|
2015-10-20 20:27:39 +00:00
|
|
|
elseif luci.http.formvalue("restart") then
|
2015-07-03 14:59:37 +00:00
|
|
|
luci.util.exec("/etc/init.d/firewall restart")
|
2009-02-08 03:56:50 +00:00
|
|
|
end
|
2015-10-20 20:27:39 +00:00
|
|
|
|
|
|
|
luci.http.redirect(luci.dispatcher.build_url("admin/status/iptables"))
|
2009-02-08 03:56:50 +00:00
|
|
|
end
|