summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-07-14 15:54:53 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-07-14 15:54:53 +0000
commit426f12416dd59cd24524fb577bdea8b2e4c440f9 (patch)
tree5ccf85da15170b26f2b8cec395cb5bd863bbae41
parentbd3d20708134c3a7622269f71d13ccb70ac0dece (diff)
* luci: add memory status patches from soma
-rw-r--r--libs/core/luasrc/sys.lua35
-rw-r--r--modules/freifunk/luasrc/controller/freifunk/freifunk.lua3
-rw-r--r--modules/freifunk/luasrc/i18n/freifunk.de.lua4
-rw-r--r--modules/freifunk/luasrc/view/public_status/index.htm14
-rw-r--r--themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css28
-rw-r--r--themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css26
6 files changed, 90 insertions, 20 deletions
diff --git a/libs/core/luasrc/sys.lua b/libs/core/luasrc/sys.lua
index e5f19f20b..d0195c5da 100644
--- a/libs/core/luasrc/sys.lua
+++ b/libs/core/luasrc/sys.lua
@@ -110,22 +110,29 @@ function sysinfo()
local c2 = "uname -m 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 c5 = "cat /proc/meminfo|grep MemTotal|cut -d: -f2 2>/dev/null"
-
- local s = luci.util.trim(exec(c1))
- local m = ""
- local r = ""
-
- if s == "" then
- s = luci.util.trim(exec(c2))
- m = luci.util.trim(exec(c3))
+ 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 system = luci.util.trim(exec(c1))
+ local model = ""
+ local memtotal = luci.util.trim(exec(c5))
+ local memcached = luci.util.trim(exec(c6))
+ local memfree = luci.util.trim(exec(c7))
+ local membuffers = luci.util.trim(exec(c8))
+ 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
- m = luci.util.trim(exec(c4))
+ model = luci.util.trim(exec(c4))
end
-
- r = luci.util.trim(exec(c5))
-
- return s, m, r
+
+ return system, model, memtotal, memcached, membuffers, memfree, perc_memfree, perc_membuffers, perc_memcached
end
-- Reads the syslog
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua
index 78cb92f2a..351a09448 100644
--- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua
+++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua
@@ -67,7 +67,8 @@ end
function action_status()
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()
diff --git a/modules/freifunk/luasrc/i18n/freifunk.de.lua b/modules/freifunk/luasrc/i18n/freifunk.de.lua
index e54e9b027..e662163a4 100644
--- a/modules/freifunk/luasrc/i18n/freifunk.de.lua
+++ b/modules/freifunk/luasrc/i18n/freifunk.de.lua
@@ -14,4 +14,8 @@ node = [[Knoten]]
note = [[Notiz]]
phone = [[Telefon]]
ram = [[Hauptspeicher]]
+free = [[Frei]]
+buffers = [[Buffers]]
+cached = [[Cached]]
+total = [[Gesamt]]
geocoord = [[Geokoordinaten]] \ No newline at end of file
diff --git a/modules/freifunk/luasrc/view/public_status/index.htm b/modules/freifunk/luasrc/view/public_status/index.htm
index 5789e3ad9..a10f22f43 100644
--- a/modules/freifunk/luasrc/view/public_status/index.htm
+++ b/modules/freifunk/luasrc/view/public_status/index.htm
@@ -20,15 +20,21 @@ $Id$
<table cellspacing="0" cellpadding="6" class="smalltext">
<tr>
<th><%:system_type%>:</th>
-<td><%=s%></td>
+<td><%=system%></td>
</tr>
<tr>
<th><%:cpu%>:</th>
-<td><%=m%></td>
+<td><%=model%></td>
</tr>
<tr>
-<th><%:ram%>:</th>
-<td><%=r%></td>
+<th><%:ram%>:<br /><small><%:total%>/<%:cached%>/<%:buffers%>/<%:free%></small></th>
+<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>
</table>
<br /><br />
diff --git a/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css b/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css
index 8f30015f3..89db2e53b 100644
--- a/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css
+++ b/themes/fledermaus/htdocs/luci-static/fledermaus/cascade.css
@@ -294,4 +294,30 @@ code {
.ok {
color: green;
font-weight: bold;
-} \ No newline at end of file
+}
+
+#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;
+}
+
diff --git a/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css b/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css
index 824b04ba4..de3246b2e 100644
--- a/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css
+++ b/themes/openwrt.org/htdocs/luci-static/openwrt.org/cascade.css
@@ -354,6 +354,31 @@ td.cbi-section-table-optionals {
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 */
* html body {
@@ -406,3 +431,4 @@ td.cbi-section-table-optionals {
* html div.cbi-value-description {
margin-left: 40%;
}
+