<% local uci = require "luci.model.uci" local fs = require "nixio.fs" local wanon = uci.inst_state:get("network", "wan", "up") == "1" local wanif = wanon and uci.inst_state:get("network", "wan", "ifname") local lanif = uci.inst_state:get("network", "lan", "ifname") local wanul, wandl, lanul, landl local devstats = fs.readfile("/proc/net/dev") local fwav = fs.access("/etc/config/firewall", "r") local fwon = uci.inst_state:get("firewall", "core", "loaded") == "1" if lanif then local rx, tx = devstats:match("%s*"..lanif.. ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+".. "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)") lanul = tx and (tonumber(tx) / 1000000000) landl = rx and (tonumber(rx) / 1000000000) end if wanif then local rx, tx = devstats:match("%s*"..wanif.. ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+".. "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)") wanul = tx and (tonumber(tx) / 1000000000) wandl = rx and (tonumber(rx) / 1000000000) end %> <% if wanul and wandl then %> <% end %> <% if lanul and landl then %> <% end %> <% if fwav then %> <% end %>
Uplink Traffic: <%=("%.2f"):format(wandl)%> GB⇓ <%=("%.2f"):format(wanul)%> GB⇑
Local Traffic: <%=("%.2f"):format(landl)%> GB⇓ <%=("%.2f"):format(lanul)%> GB⇑
Firewall: <%=fwon and translate("active") or translate("inactive")%>