modules/admin-full: Add swap info to admin_status page if swap is available, #533
This commit is contained in:
parent
e2b94c2fde
commit
5b129819cc
2 changed files with 40 additions and 3 deletions
|
@ -176,6 +176,9 @@ function sysinfo()
|
||||||
local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)"))
|
local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)"))
|
||||||
local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)"))
|
local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)"))
|
||||||
local bogomips = tonumber(cpuinfo:match("[Bb]ogo[Mm][Ii][Pp][Ss].-: ([^\n]+)")) or 0
|
local bogomips = tonumber(cpuinfo:match("[Bb]ogo[Mm][Ii][Pp][Ss].-: ([^\n]+)")) or 0
|
||||||
|
local swaptotal = tonumber(meminfo:match("SwapTotal:%s*(%d+)"))
|
||||||
|
local swapcached = tonumber(meminfo:match("SwapCached:%s*(%d+)"))
|
||||||
|
local swapfree = tonumber(meminfo:match("SwapFree:%s*(%d+)"))
|
||||||
|
|
||||||
local system =
|
local system =
|
||||||
cpuinfo:match("system type\t+: ([^\n]+)") or
|
cpuinfo:match("system type\t+: ([^\n]+)") or
|
||||||
|
@ -190,7 +193,7 @@ function sysinfo()
|
||||||
nixio.uname().machine or
|
nixio.uname().machine or
|
||||||
system
|
system
|
||||||
|
|
||||||
return system, model, memtotal, memcached, membuffers, memfree, bogomips
|
return system, model, memtotal, memcached, membuffers, memfree, bogomips, swaptotal, swapcached, swapfree
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Retrieves the output of the "logread" command.
|
--- Retrieves the output of the "logread" command.
|
||||||
|
|
|
@ -19,14 +19,17 @@ You may obtain a copy of the License at
|
||||||
local has_dhcp = luci.fs.access("/etc/config/dhcp")
|
local has_dhcp = luci.fs.access("/etc/config/dhcp")
|
||||||
local has_wifi = luci.fs.stat("/etc/config/wireless")
|
local has_wifi = luci.fs.stat("/etc/config/wireless")
|
||||||
has_wifi = has_wifi and has_wifi.size > 0
|
has_wifi = has_wifi and has_wifi.size > 0
|
||||||
|
local _, _, memtotal, memcached, membuffers, memfree, _, swaptotal, swapcached, swapfree = luci.sys.sysinfo()
|
||||||
|
local has_swap
|
||||||
|
if swaptotal > 0 then
|
||||||
|
has_swap = 1
|
||||||
|
end
|
||||||
|
|
||||||
if luci.http.formvalue("status") == "1" then
|
if luci.http.formvalue("status") == "1" then
|
||||||
local ntm = require "luci.model.network".init()
|
local ntm = require "luci.model.network".init()
|
||||||
local wan = ntm:get_wannet()
|
local wan = ntm:get_wannet()
|
||||||
local wan6 = ntm:get_wan6net()
|
local wan6 = ntm:get_wan6net()
|
||||||
|
|
||||||
local _, _, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
|
|
||||||
|
|
||||||
local conn_count = tonumber((
|
local conn_count = tonumber((
|
||||||
luci.sys.exec("wc -l /proc/net/nf_conntrack") or
|
luci.sys.exec("wc -l /proc/net/nf_conntrack") or
|
||||||
luci.sys.exec("wc -l /proc/net/ip_conntrack") or
|
luci.sys.exec("wc -l /proc/net/ip_conntrack") or
|
||||||
|
@ -45,6 +48,9 @@ You may obtain a copy of the License at
|
||||||
memcached = memcached,
|
memcached = memcached,
|
||||||
membuffers = membuffers,
|
membuffers = membuffers,
|
||||||
memfree = memfree,
|
memfree = memfree,
|
||||||
|
swaptotal = swaptotal,
|
||||||
|
swapcached = swapcached,
|
||||||
|
swapfree = swapfree,
|
||||||
connmax = conn_max,
|
connmax = conn_max,
|
||||||
conncount = conn_count,
|
conncount = conn_count,
|
||||||
leases = luci.tools.status.dhcp_leases(),
|
leases = luci.tools.status.dhcp_leases(),
|
||||||
|
@ -494,6 +500,22 @@ You may obtain a copy of the License at
|
||||||
info.membuffers + " <%:kB%>", info.memtotal + " <%:kB%>"
|
info.membuffers + " <%:kB%>", info.memtotal + " <%:kB%>"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (e = document.getElementById('swapcache'))
|
||||||
|
e.innerHTML = progressbar(
|
||||||
|
info.swapcached + " <%:kB%>", info.swaptotal + " <%:kB%>"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (e = document.getElementById('swaptotal'))
|
||||||
|
e.innerHTML = progressbar(
|
||||||
|
(info.swapfree + info.swapcached) + " <%:kB%>",
|
||||||
|
info.swaptotal + " <%:kB%>"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (e = document.getElementById('swapfree'))
|
||||||
|
e.innerHTML = progressbar(
|
||||||
|
info.swapfree + " <%:kB%>", info.swaptotal + " <%:kB%>"
|
||||||
|
);
|
||||||
|
|
||||||
if (e = document.getElementById('conns'))
|
if (e = document.getElementById('conns'))
|
||||||
e.innerHTML = progressbar(info.conncount, info.connmax);
|
e.innerHTML = progressbar(info.conncount, info.connmax);
|
||||||
|
|
||||||
|
@ -531,6 +553,18 @@ You may obtain a copy of the License at
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<% if has_swap then %>
|
||||||
|
<fieldset class="cbi-section">
|
||||||
|
<legend><%:Swap%></legend>
|
||||||
|
|
||||||
|
<table width="100%" cellspacing="10">
|
||||||
|
<tr><td width="33%"><%:Total Available%></td><td id="swaptotal">-</td></tr>
|
||||||
|
<tr><td width="33%"><%:Free%></td><td id="swapfree">-</td></tr>
|
||||||
|
<tr><td width="33%"><%:Cached%></td><td id="swapcache">-</td></tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<fieldset class="cbi-section">
|
<fieldset class="cbi-section">
|
||||||
<legend><%:Network%></legend>
|
<legend><%:Network%></legend>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue