2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 module("luci.controller.admin.status", package.seeall)
17 luci.i18n.loadc("base")
18 local i18n = luci.i18n.translate
20 entry({"admin", "status"}, template("admin_status/index"), i18n("Status"), 20).index = true
21 entry({"admin", "status", "interfaces"}, template("admin_status/interfaces"), i18n("Interfaces"), 1)
22 entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("Firewall"), 2)
23 entry({"admin", "status", "conntrack"}, template("admin_status/conntrack"), i18n("Active Connections"), 3)
24 entry({"admin", "status", "routes"}, template("admin_status/routes"), i18n("Routes"), 4)
25 entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("System Log"), 5)
26 entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("Kernel Log"), 6)
28 entry({"admin", "status", "bandwidth"}, template("admin_status/bandwidth"), i18n("Realtime Traffic"), 7).leaf = true
29 entry({"admin", "status", "bandwidth_status"}, call("action_bandwidth")).leaf = true
33 function action_syslog()
34 local syslog = luci.sys.syslog()
35 luci.template.render("admin_status/syslog", {syslog=syslog})
38 function action_dmesg()
39 local dmesg = luci.sys.dmesg()
40 luci.template.render("admin_status/dmesg", {dmesg=dmesg})
43 function action_iptables()
44 if luci.http.formvalue("zero") == "1" then
45 luci.util.exec("iptables -Z")
47 luci.dispatcher.build_url("admin", "status", "iptables")
49 elseif luci.http.formvalue("restart") == "1" then
50 luci.util.exec("/etc/init.d/firewall restart")
52 luci.dispatcher.build_url("admin", "status", "iptables")
55 luci.template.render("admin_status/iptables")
59 function action_bandwidth()
60 local path = luci.dispatcher.context.requestpath
61 local iface = path[#path]
63 local fs = require "luci.fs"
64 if fs.access("/var/lib/luci-bwc/%s" % iface) then
65 luci.http.prepare_content("application/json")
67 local bwc = io.popen("luci-bwc -p %q 2>/dev/null" % iface)
72 local ln = bwc:read("*l")
73 if not ln then break end
84 luci.http.status(404, "No such interface")