* luci: add memory status patches from soma
This commit is contained in:
parent
bd3d207081
commit
426f12416d
6 changed files with 89 additions and 19 deletions
|
@ -110,22 +110,29 @@ function sysinfo()
|
||||||
local c2 = "uname -m 2>/dev/null"
|
local c2 = "uname -m 2>/dev/null"
|
||||||
local c3 = "cat /proc/cpuinfo|grep model\\ name|cut -d: -f2 2>/dev/null"
|
local c3 = "cat /proc/cpuinfo|grep model\\ name|cut -d: -f2 2>/dev/null"
|
||||||
local c4 = "cat /proc/cpuinfo|grep cpu\\ model|cut -d: -f2 2>/dev/null"
|
local c4 = "cat /proc/cpuinfo|grep cpu\\ model|cut -d: -f2 2>/dev/null"
|
||||||
local c5 = "cat /proc/meminfo|grep MemTotal|cut -d: -f2 2>/dev/null"
|
local c5 = "cat /proc/meminfo|grep MemTotal|awk {' print $2 '} 2>/dev/null"
|
||||||
|
local c6 = "cat /proc/meminfo|grep ^Cached|awk {' print $2 '} 2>/dev/null"
|
||||||
|
local c7 = "cat /proc/meminfo|grep MemFree|awk {' print $2 '} 2>/dev/null"
|
||||||
|
local c8 = "cat /proc/meminfo|grep Buffers|awk {' print $2 '} 2>/dev/null"
|
||||||
|
|
||||||
local s = luci.util.trim(exec(c1))
|
local system = luci.util.trim(exec(c1))
|
||||||
local m = ""
|
local model = ""
|
||||||
local r = ""
|
local memtotal = luci.util.trim(exec(c5))
|
||||||
|
local memcached = luci.util.trim(exec(c6))
|
||||||
if s == "" then
|
local memfree = luci.util.trim(exec(c7))
|
||||||
s = luci.util.trim(exec(c2))
|
local membuffers = luci.util.trim(exec(c8))
|
||||||
m = luci.util.trim(exec(c3))
|
local perc_memfree = math.floor((memfree/memtotal)*100)
|
||||||
|
local perc_membuffers = math.floor((membuffers/memtotal)*100)
|
||||||
|
local perc_memcached = math.floor((memcached/memtotal)*100)
|
||||||
|
|
||||||
|
if system == "" then
|
||||||
|
system = luci.util.trim(exec(c2))
|
||||||
|
model = luci.util.trim(exec(c3))
|
||||||
else
|
else
|
||||||
m = luci.util.trim(exec(c4))
|
model = luci.util.trim(exec(c4))
|
||||||
end
|
end
|
||||||
|
|
||||||
r = luci.util.trim(exec(c5))
|
return system, model, memtotal, memcached, membuffers, memfree, perc_memfree, perc_membuffers, perc_memcached
|
||||||
|
|
||||||
return s, m, r
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Reads the syslog
|
-- Reads the syslog
|
||||||
|
|
|
@ -67,7 +67,8 @@ end
|
||||||
function action_status()
|
function action_status()
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
data.s, data.m, data.r = luci.sys.sysinfo()
|
data.system, data.model, data.memtotal, data.memcached, data.membuffers, data.memfree, data.perc_memfree, data.perc_membuffers, data.perc_memcached = luci.sys.sysinfo()
|
||||||
|
|
||||||
|
|
||||||
data.wifi = luci.sys.wifi.getiwconfig()
|
data.wifi = luci.sys.wifi.getiwconfig()
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,8 @@ node = [[Knoten]]
|
||||||
note = [[Notiz]]
|
note = [[Notiz]]
|
||||||
phone = [[Telefon]]
|
phone = [[Telefon]]
|
||||||
ram = [[Hauptspeicher]]
|
ram = [[Hauptspeicher]]
|
||||||
|
free = [[Frei]]
|
||||||
|
buffers = [[Buffers]]
|
||||||
|
cached = [[Cached]]
|
||||||
|
total = [[Gesamt]]
|
||||||
geocoord = [[Geokoordinaten]]
|
geocoord = [[Geokoordinaten]]
|
|
@ -20,15 +20,21 @@ $Id$
|
||||||
<table cellspacing="0" cellpadding="6" class="smalltext">
|
<table cellspacing="0" cellpadding="6" class="smalltext">
|
||||||
<tr>
|
<tr>
|
||||||
<th><%:system_type%>:</th>
|
<th><%:system_type%>:</th>
|
||||||
<td><%=s%></td>
|
<td><%=system%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%:cpu%>:</th>
|
<th><%:cpu%>:</th>
|
||||||
<td><%=m%></td>
|
<td><%=model%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%:ram%>:</th>
|
<th><%:ram%>:<br /><small><%:total%>/<%:cached%>/<%:buffers%>/<%:free%></small></th>
|
||||||
<td><%=r%></td>
|
<td><%=memtotal%> / <%=memcached%> / <%=membuffers%> / <%=memfree%> KB<br />
|
||||||
|
<div id="memorybar">
|
||||||
|
<div id="memfree" style="width:<%=perc_memfree%>%"></div>
|
||||||
|
<div id="membuffers" style="width:<%=perc_membuffers%>%"></div>
|
||||||
|
<div id="memcached" style="width:<%=perc_memcached%>%"></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
|
@ -294,4 +294,30 @@ code {
|
||||||
.ok {
|
.ok {
|
||||||
color: green;
|
color: green;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#memorybar {
|
||||||
|
width:200px;
|
||||||
|
height:9px;
|
||||||
|
border:1px solid #bbb;
|
||||||
|
background-color: #262626;
|
||||||
|
}
|
||||||
|
|
||||||
|
#memfree, #membuffers, #memcached {
|
||||||
|
float:right;
|
||||||
|
border:1px solid #262626;
|
||||||
|
height:7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#memfree {
|
||||||
|
background-color:green;
|
||||||
|
}
|
||||||
|
|
||||||
|
#membuffers {
|
||||||
|
background-color:#ffcb05;
|
||||||
|
}
|
||||||
|
|
||||||
|
#memcached {
|
||||||
|
background-color:#dc0065;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,6 +354,31 @@ td.cbi-section-table-optionals {
|
||||||
font-size: 70%;
|
font-size: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#memorybar {
|
||||||
|
width:200px;
|
||||||
|
height:8px;
|
||||||
|
border:1px solid #bbb;
|
||||||
|
background-color:red
|
||||||
|
}
|
||||||
|
|
||||||
|
#memfree, #membuffers, #memcached {
|
||||||
|
float:right;
|
||||||
|
border:1px solid #bbb;
|
||||||
|
height:6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#memfree {
|
||||||
|
background-color:green;
|
||||||
|
}
|
||||||
|
|
||||||
|
#membuffers {
|
||||||
|
background-color:yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
#memcached {
|
||||||
|
background-color:orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* obligatory IE6 Voodoo Code */
|
/* obligatory IE6 Voodoo Code */
|
||||||
* html body {
|
* html body {
|
||||||
|
@ -406,3 +431,4 @@ td.cbi-section-table-optionals {
|
||||||
* html div.cbi-value-description {
|
* html div.cbi-value-description {
|
||||||
margin-left: 40%;
|
margin-left: 40%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue