2 local uci = require
"luci.model.uci"
3 local fs = require
"nixio.fs"
5 local wanon = uci.inst_state:get(
"network",
"wan",
"up") ==
"1"
6 local wanif = wanon and uci.inst_state:get(
"network",
"wan",
"ifname")
7 local lanif = uci.inst_state:get(
"network",
"lan",
"ifname")
8 local wanul, wandl, lanul, landl
9 local devstats = fs.readfile(
"/proc/net/dev")
11 local fwav = fs.access(
"/etc/config/firewall",
"r")
12 local fwon = uci.inst_state:get(
"firewall",
"core",
"loaded") ==
"1"
15 local rx, tx = devstats:match(
"%s*"..lanif..
16 ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+"..
17 "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)")
18 lanul = tx and (tonumber(tx) /
1000000000)
19 landl = rx and (tonumber(rx) /
1000000000)
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)
32 <table class=
"dbstattbl">
33 <% if wanul and wandl then %
>
35 <th>Uplink Traffic:
</th><td>
36 <%=(
"%.2f"):format(wandl)%
> GB
⇓ <%=(
"%.2f"):format(wanul)%
> GB
⇑
41 <% if lanul and landl then %
>
43 <th>Local Traffic:
</th><td>
44 <%=(
"%.2f"):format(landl)%
> GB
⇓ <%=(
"%.2f"):format(lanul)%
> GB
⇑
51 <th>Firewall:
</th><td>
52 <%=fwon and translate(
"active") or translate(
"inactive")%
>