2 local uci = require "luci.model.uci"
3 local fs = require "nixio.fs"
6 uci.inst_state:foreach("network", "interface", function(s)
10 if uci.inst_state:get("network", "lan", "_ipchanged") and
11 uci.inst_state:revert("network", "lan", "_ipchanged") then
12 include("niu/network/warn_ip_change")
15 local wanon = uci.inst_state:get("network", "wan", "proto")
16 local wanup = uci.inst_state:get("network", "wan", "up")
17 local wanip = uci.inst_state:get("network", "wan", "ipaddr")
18 local wanif = uci.inst_state:get("network", "wan", "ifname")
22 local devstats = fs.readfile("/proc/net/dev")
23 local rx, tx = devstats:match("%s*"..wanif..
24 ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+"..
25 "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)")
26 wanul = tx and (tonumber(tx) / 1000000000)
27 wandl = rx and (tonumber(rx) / 1000000000)
31 uci.inst:foreach("dhcp", "dnsmasq",
33 leasefn = section.leasefile
38 local ln = io.lines(leasefn)
46 if fs.access("/proc/net/arp", "r") then
47 local ln = io.lines("/proc/net/arp")
52 arps = arps >= 0 and arps
56 <table class="dbstattbl">
57 <% if wanon and wanon ~= "none" then %>
60 <th>Uplink Address</th>
61 <td><span style="color: darkgreen"><%=wanip%></span>
65 <td><span style="color: darkred"><em>offline</em></span>
72 <% if wanul and wandl then %>
74 <th>Uplink Traffic</th><td>
75 <%=("%.2f"):format(wandl)%> GB⇓ <%=("%.2f"):format(wanul)%> GB⇑
81 <th>Local Address</th><td>
82 <%=uci.inst_state:get("network", "lan", "ipaddr")%>
88 <th>Active IP-Devices</th><td><%=arps%><% if leasefn then %>
89 (<%=leasefn%> assigned)