2 local sys = require
"luci.sys"
3 local twa = require
"luci.tools.webadmin"
5 local system, model, memtotal, memcached, membuffers, memfree = sys.sysinfo()
6 local uptime = twa.date_format(tonumber(sys.uptime()))
7 local_time = os.date(
"%c")
8 local load1, load5, load15 = sys.loadavg()
9 local load = string.format(
"%.2f, %.2f, %.2f", load1, load5, load15)
10 local memory = string.format(
"%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
11 tonumber(memtotal) /
1024,
12 100 * memcached / memtotal,
13 tostring(translate(
"cached")),
14 100 * membuffers / memtotal,
15 tostring(translate(
"buffered")),
16 100 * memfree / memtotal,
17 tostring(translate(
"free"))
21 local ntm = require
"luci.model.network".init()
22 local devices = ntm:get_wifidevs()
26 local has_iwinfo = pcall(require,
"iwinfo")
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>
52 <% if not has_iwinfo then %
>
53 <div class=
"errorbox">
54 <strong><%:Package libiwinfo required!%
></strong><br />
55 <%_The
<em>libiwinfo
</em> package is not installed. You must install this component for working wireless configuration!%
>
59 <div class=
"cbi-section">
60 <div class=
"cbi-section-node">
61 <table class=
"cbi-section-table">
62 <tr class=
"cbi-section-table-titles">
63 <th class=
"cbi-section-table-cell"><%:Signal%
></th>
64 <th class=
"cbi-section-table-cell"><%:Bitrate%
></th>
65 <th class=
"cbi-section-table-cell"><%:SSID%
></th>
66 <th class=
"cbi-section-table-cell"><%:BSSID%
></th>
67 <th class=
"cbi-section-table-cell"><%:Channel%
></th>
68 <th class=
"cbi-section-table-cell"><%:Mode%
></th>
69 <th class=
"cbi-section-table-cell"><%:TX%
>-<%:Power%
></th>
70 <th class=
"cbi-section-table-cell"><%:Interface%
></th>
73 for _, dev in ipairs(devices) do
75 for _, net in ipairs(dev:get_wifinets()) do
76 netlist[#netlist+
1] = net:ifname()
77 netdevs[net:ifname()] = dev:name()
79 if net.iwdata.ifname then
80 local signal = net.iwinfo.signal or
"N/A"
81 local noise = net.iwinfo.noise or
"N/A"
82 local q = net.iwinfo.quality or
"0"
83 local qmax = net.iwinfo.quality_max or
"100"
84 local qperc = q / qmax *
100
87 icon =
"signal-none.png"
88 elseif qperc <
26 then
89 icon =
"signal-0-25.png"
90 elseif qperc <
51 then
91 icon =
"signal-25-50.png"
92 elseif qperc <
76 then
93 icon =
"signal-50-75.png"
94 elseif qperc <
100 then
95 icon =
"signal-75-100.png"
100 signal_string =
"<img src='"..resource..
"/icons/"..icon..
"' title='Signal: "..signal..
" db / Noise: "..noise..
" db' alt='Signal Quality'></img>"
102 local ssid = net.iwinfo.ssid or
"N/A"
103 local bssid = net.iwinfo.bssid or
"N/A"
104 local chan = net.iwinfo.channel or
"N/A"
105 local mode = net.iwinfo.mode or
"N/A"
106 local txpwr = net.iwinfo.txpower or
"N/A"
107 if txpwr ~=
"N/A" then
108 txpwr = txpwr..
" dbm"
110 local bitrate = net.iwinfo.bitrate or
"N/A"
111 if bitrate ~=
"N/A" then
112 bitrate = ( bitrate /
1000 )..
"Mb/s"
114 local interface = net.iwdata.ifname or
"N/A"
116 <tr class=
"cbi-section-table-row cbi-rowstyle-1">
117 <td class=
"cbi-value-field"><%=signal_string%
></td>
118 <td class=
"cbi-value-field"><%=bitrate%
></td>
119 <td class=
"cbi-value-field"><%=ssid%
></td>
120 <td class=
"cbi-value-field"><%=bssid%
></td>
121 <td class=
"cbi-value-field"><%=chan%
></td>
122 <td class=
"cbi-value-field"><%=mode%
></td>
123 <td class=
"cbi-value-field"><%=txpwr%
></td>
124 <td class=
"cbi-value-field"><%=interface%
></td>
135 <div class=
"cbi-map">
136 <h2><%:Default routes%
></h2>
137 <div class=
"cbi-section">
138 <div class=
"cbi-section-node">
139 <table class=
"cbi-section-table">
141 <% if not defroutev4 and not defroutev6 then %
>
142 <%:No default routes known.%
>
144 <tr class=
"cbi-section-table-titles">
145 <th class=
"cbi-section-table-cell"><%:Network%
></th>
146 <th class=
"cbi-section-table-cell"><%:Interface%
></th>
147 <th class=
"cbi-section-table-cell"><%:Gateway%
></th>
148 <th class=
"cbi-section-table-cell"><%:Metric%
></th>
151 <% if defroutev4 then %
>
153 <tr class=
"cbi-section-table-row cbi-rowstyle-1">
154 <td class=
"cbi-value-field"><%=defroutev4.dest:string()%
></td>
155 <td class=
"cbi-value-field"><%=defroutev4.device%
></td>
156 <td class=
"cbi-value-field"><%=defroutev4.gateway:string()%
></td>
157 <td class=
"cbi-value-field"><%=defroutev4.metric%
></td>
161 if defroutev6 then %
>
163 <tr class=
"cbi-section-table-row cbi-rowstyle-2">
164 <td class=
"cbi-value-field"><%=defroutev6.dest:string()%
></td>
165 <td class=
"cbi-value-field"><%=defroutev6.device%
></td>
166 <td class=
"cbi-value-field"><%=defroutev6.nexthop:string()%
></td>
167 <td class=
"cbi-value-field"><%=defroutev6.metric%
></td>