2 local sys = require
"luci.sys"
3 local twa = require
"luci.tools.webadmin"
6 local system, model, memtotal, memcached, membuffers, memfree = sys.sysinfo()
7 local uptime = twa.date_format(tonumber(sys.uptime()))
8 local_time = os.date(
"%c")
9 local load1, load5, load15 = sys.loadavg()
10 local load = string.format(
"%.2f, %.2f, %.2f", load1, load5, load15)
11 local memory = string.format(
"%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
12 tonumber(memtotal) /
1024,
13 100 * memcached / memtotal,
14 tostring(translate(
"cached")),
15 100 * membuffers / memtotal,
16 tostring(translate(
"buffered")),
17 100 * memfree / memtotal,
18 tostring(translate(
"free"))
22 local ntm = require
"luci.model.network".init()
23 local devices = ntm:get_wifidevs()
29 local defroutev4 = sys.net.defaultroute()
30 local defroutev6 = sys.net.defaultroute6 ()
37 <div class=
"cbi-section-node">
38 <div class=
"cbi-value"><label class=
"cbi-value-title"><%:System%
></label><div class=
"cbi-value-field"><%=system%
></div></div>
39 <div class=
"cbi-value"><label class=
"cbi-value-title"><%:Processor%
></label><div class=
"cbi-value-field"><%=model%
></div></div>
40 <div class=
"cbi-value"><label class=
"cbi-value-title"><%:Load%
></label><div class=
"cbi-value-field"><%=load%
></div></div>
41 <div class=
"cbi-value"><label class=
"cbi-value-title"><%:Memory%
></label><div class=
"cbi-value-field"><%=memory%
></div></div>
42 <div class=
"cbi-value"><label class=
"cbi-value-title"><%:Local Time%
></label><div class=
"cbi-value-field"><%=local_time%
></div></div>
43 <div class=
"cbi-value"><label class=
"cbi-value-title"><%:Uptime%
></label><div class=
"cbi-value-field"><%=uptime%
></div></div>
47 <% if devices[
1] then %
>
50 <h2><%:Wireless Overview%
></h2>
51 <div class=
"cbi-section">
52 <div class=
"cbi-section-node">
53 <table class=
"cbi-section-table">
54 <tr class=
"cbi-section-table-titles">
55 <th class=
"cbi-section-table-cell"><%:Signal%
></th>
56 <th class=
"cbi-section-table-cell"><%:Bitrate%
></th>
57 <th class=
"cbi-section-table-cell"><%:SSID%
></th>
58 <th class=
"cbi-section-table-cell"><%:BSSID%
></th>
59 <th class=
"cbi-section-table-cell"><%:Channel%
></th>
60 <th class=
"cbi-section-table-cell"><%:Mode%
></th>
61 <th class=
"cbi-section-table-cell"><%:TX%
>-<%:Power%
></th>
62 <th class=
"cbi-section-table-cell"><%:Interface%
></th>
65 for _, dev in ipairs(devices) do
67 for _, net in ipairs(dev:get_wifinets()) do
68 netlist[#netlist+
1] = net:ifname()
69 netdevs[net:ifname()] = dev:name()
71 if net.iwdata.ifname then
72 local signal = net.iwinfo.signal or
"N/A"
73 local noise = net.iwinfo.noise or
"N/A"
74 local q = net.iwinfo.quality or
"0"
75 local qmax = net.iwinfo.quality_max or
"100"
76 local qperc = q / qmax *
100
79 icon =
"signal-none.png"
80 elseif qperc <
26 then
81 icon =
"signal-0-25.png"
82 elseif qperc <
51 then
83 icon =
"signal-25-50.png"
84 elseif qperc <
76 then
85 icon =
"signal-50-75.png"
86 elseif qperc <
100 then
87 icon =
"signal-75-100.png"
92 signal_string =
"<img src='"..resource..
"/icons/"..icon..
"' title='Signal: "..signal..
" db / Noise: "..noise..
" db' alt='Signal Quality'></img>"
94 local ssid = net.iwinfo.ssid or
"N/A"
95 local bssid = net.iwinfo.bssid or
"N/A"
96 local chan = net.iwinfo.channel or
"N/A"
97 local mode = net.iwinfo.mode or
"N/A"
98 local txpwr = net.iwinfo.txpower or
"N/A"
99 if txpwr ~=
"N/A" then
100 txpwr = txpwr..
" dbm"
102 local bitrate = net.iwinfo.bitrate or
"N/A"
103 if bitrate ~=
"N/A" then
104 bitrate = ( bitrate /
1000 )..
"Mb/s"
106 local interface = net.iwdata.ifname or
"N/A"
108 <tr class=
"cbi-section-table-row cbi-rowstyle-1">
109 <td class=
"cbi-value-field"><%=signal_string%
></td>
110 <td class=
"cbi-value-field"><%=bitrate%
></td>
111 <td class=
"cbi-value-field"><%=ssid%
></td>
112 <td class=
"cbi-value-field"><%=bssid%
></td>
113 <td class=
"cbi-value-field"><%=chan%
></td>
114 <td class=
"cbi-value-field"><%=mode%
></td>
115 <td class=
"cbi-value-field"><%=txpwr%
></td>
116 <td class=
"cbi-value-field"><%=interface%
></td>
127 <div class=
"cbi-map">
128 <h2><%:Default routes%
></h2>
129 <div class=
"cbi-section">
130 <div class=
"cbi-section-node">
131 <table class=
"cbi-section-table">
133 <% if not defroutev4 and not defroutev6 then %
>
134 <%:No defaultroutes known.%
>
136 <tr class=
"cbi-section-table-titles">
137 <th class=
"cbi-section-table-cell"><%:Network%
></th>
138 <th class=
"cbi-section-table-cell"><%:Interface%
></th>
139 <th class=
"cbi-section-table-cell"><%:Gateway%
></th>
140 <th class=
"cbi-section-table-cell"><%:Metric%
></th>
143 <% if defroutev4 then %
>
145 <tr class=
"cbi-section-table-row cbi-rowstyle-1">
146 <td class=
"cbi-value-field"><%=defroutev4.dest:string()%
></td>
147 <td class=
"cbi-value-field"><%=defroutev4.device%
></td>
148 <td class=
"cbi-value-field"><%=defroutev4.gateway:string()%
></td>
149 <td class=
"cbi-value-field"><%=defroutev4.metric%
></td>
153 if defroutev6 then %
>
155 <tr class=
"cbi-section-table-row cbi-rowstyle-2">
156 <td class=
"cbi-value-field"><%=defroutev6.dest:string()%
></td>
157 <td class=
"cbi-value-field"><%=defroutev6.device%
></td>
158 <td class=
"cbi-value-field"><%=defroutev6.nexthop:string()%
></td>
159 <td class=
"cbi-value-field"><%=defroutev6.metric%
></td>