From 58d97b5e271bc0d7507eab5b9bd2902181864e02 Mon Sep 17 00:00:00 2001 From: "Daniel F. Dickinson" Date: Fri, 3 Aug 2018 12:36:51 -0400 Subject: modules: Split luci-mod-full Move some common elements to luci-base, and otherwise make three packages out of status, system, and network. They were mostly separated already, but there were some shared elements between status and network that are now in luci-base. Signed-off-by: Daniel F. Dickinson --- .../luasrc/view/admin_status/index.htm | 487 +++++++++++++++++++++ 1 file changed, 487 insertions(+) create mode 100644 modules/luci-mod-status/luasrc/view/admin_status/index.htm (limited to 'modules/luci-mod-status/luasrc/view/admin_status/index.htm') diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index.htm b/modules/luci-mod-status/luasrc/view/admin_status/index.htm new file mode 100644 index 0000000000..3edfd92047 --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/index.htm @@ -0,0 +1,487 @@ +<%# + Copyright 2008 Steven Barth + Copyright 2008-2011 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-%> + +<% + local fs = require "nixio.fs" + local ipc = require "luci.ip" + local util = require "luci.util" + local stat = require "luci.tools.status" + local ver = require "luci.version" + + local has_ipv6 = fs.access("/proc/net/ipv6_route") + local has_dhcp = fs.access("/etc/config/dhcp") + local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) + + local sysinfo = luci.util.ubus("system", "info") or { } + local boardinfo = luci.util.ubus("system", "board") or { } + local unameinfo = nixio.uname() or { } + + local meminfo = sysinfo.memory or { + total = 0, + free = 0, + buffered = 0, + shared = 0 + } + + local swapinfo = sysinfo.swap or { + total = 0, + free = 0 + } + + local has_dsl = fs.access("/etc/init.d/dsl_control") + + if luci.http.formvalue("status") == "1" then + local ntm = require "luci.model.network".init() + local wan_nets = ntm:get_wan_networks() + local wan6_nets = ntm:get_wan6_networks() + + local conn_count = tonumber( + fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0 + + local conn_max = tonumber(luci.sys.exec( + "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max" + ):match("%d+")) or 4096 + + local rv = { + uptime = sysinfo.uptime or 0, + localtime = os.date(), + loadavg = sysinfo.load or { 0, 0, 0 }, + memory = meminfo, + swap = swapinfo, + connmax = conn_max, + conncount = conn_count, + wifinets = stat.wifi_networks() + } + + if #wan_nets > 0 then + local k, v + + rv.wan = { } + + for k, v in pairs(wan_nets) do + local dev = v:get_interface() + local link = dev and ipc.link(dev:name()) + + local wan_info = { + ipaddr = v:ipaddr(), + gwaddr = v:gwaddr(), + netmask = v:netmask(), + dns = v:dnsaddrs(), + expires = v:expires(), + uptime = v:uptime(), + proto = v:proto(), + i18n = v:get_i18n(), + ifname = v:ifname(), + link = v:adminlink(), + mac = dev and dev:mac(), + type = dev and dev:type(), + name = dev and dev:get_i18n(), + ether = link and link.type == 1 + } + + rv.wan[#rv.wan+1] = wan_info + end + end + + if #wan6_nets > 0 then + local k, v + + rv.wan6 = { } + + for k, v in pairs(wan6_nets) do + local dev = v:get_interface() + local link = dev and ipc.link(dev:name()) + local wan6_info = { + ip6addr = v:ip6addr(), + gw6addr = v:gw6addr(), + dns = v:dns6addrs(), + ip6prefix = v:ip6prefix(), + uptime = v:uptime(), + proto = v:proto(), + i18n = v:get_i18n(), + ifname = v:ifname(), + link = v:adminlink(), + mac = dev and dev:mac(), + type = dev and dev:type(), + name = dev and dev:get_i18n(), + ether = link and link.type == 1 + } + + rv.wan6[#rv.wan6+1] = wan6_info + end + end + + if has_dsl then + local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") + local dsl_func = loadstring(dsl_stat) + if dsl_func then + rv.dsl = dsl_func() + end + end + + luci.http.prepare_content("application/json") + luci.http.write_json(rv) + + return + end +-%> + +<%+header%> + + + +

<%:Status%>

+ +
+

<%:System%>

+ +
+
<%:Hostname%>
<%=luci.sys.hostname() or "?"%>
+
<%:Model%>
<%=pcdata(boardinfo.model or "?")%>
+
<%:Architecture%>
<%=pcdata(boardinfo.system or "?")%>
+
<%:Firmware Version%>
+ <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> / + <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>) +
+
<%:Kernel Version%>
<%=unameinfo.release or "?"%>
+
<%:Local Time%>
-
+
<%:Uptime%>
-
+
<%:Load Average%>
-
+
+
+ +
+

<%:Memory%>

+ +
+
<%:Total Available%>
-
+
<%:Free%>
-
+
<%:Buffered%>
-
+
+
+ +<% if swapinfo.total > 0 then %> +
+

<%:Swap%>

+ +
+
<%:Total Available%>
-
+
<%:Free%>
-
+
+
+<% end %> + +
+

<%:Network%>

+ +
+

<%:Collecting data...%>

+
+ +
+
<%:Active Connections%>
-
+
+
+ +<% + if has_dhcp then + include("lease_status") + end +%> + +<% if has_dsl then %> +
+

<%:DSL%>

+ +
+

<%:Collecting data...%>

+
+
+<% end %> + +<% if has_wifi then %> +
+

<%:Wireless%>

+ +
+

<%:Collecting data...%>

+
+
+ +
+

<%:Associated Stations%>

+ + <%+wifi_assoclist%> +
+<% end %> + +<%- + local incdir = util.libpath() .. "/view/admin_status/index/" + if fs.access(incdir) then + local inc + for inc in fs.dir(incdir) do + if inc:match("%.htm$") then + include("admin_status/index/" .. inc:gsub("%.htm$", "")) + end + end + end +-%> + +<%+footer%> -- cgit v1.2.3