Added status information
authorSteven Barth <steven@midlink.org>
Sat, 16 Aug 2008 23:17:50 +0000 (23:17 +0000)
committerSteven Barth <steven@midlink.org>
Sat, 16 Aug 2008 23:17:50 +0000 (23:17 +0000)
Minor Cleanups

i18n/english/luasrc/i18n/admin-core.en.lua
i18n/german/luasrc/i18n/admin-core.de.lua
libs/sys/luasrc/sys.lua
modules/admin-full/luasrc/controller/admin/network.lua
modules/admin-full/luasrc/controller/admin/system.lua
modules/admin-full/luasrc/model/cbi/admin_system/system.lua
modules/admin-full/luasrc/view/admin_network/index.htm [deleted file]
modules/admin-full/luasrc/view/admin_system/index.htm [deleted file]
modules/freifunk/luasrc/controller/freifunk/freifunk.lua

index 0ab6f99..c516b31 100644 (file)
@@ -271,4 +271,8 @@ process_cpu = "CPU usage (%)"
 process_mem = "Memory usage (%)"
 process_hup = "Hang Up"
 process_term = "Terminate"
-process_kill = "Kill"
\ No newline at end of file
+process_kill = "Kill"
+
+mem_cached = "cached"
+mem_buffered = "buffered"
+mem_free = "free"
\ No newline at end of file
index e5e01a4..449d86f 100644 (file)
@@ -346,4 +346,8 @@ process_cpu = "CPU-Nutzung (%)"
 process_mem = "Speichernutzung (%)"
 process_hup = "Auflegen"
 process_term = "Beenden"
-process_kill = "Töten"
\ No newline at end of file
+process_kill = "Töten"
+
+mem_cached = "gecached"
+mem_buffered = "gepuffert"
+mem_free = "frei"
\ No newline at end of file
index 6b6ea70..970dcff 100644 (file)
@@ -124,9 +124,6 @@ end
 -- @return     String containing the memory used for caching in kB
 -- @return     String containing the memory used for buffering in kB
 -- @return     String containing the free memory amount in kB
--- @return     Number containing free memory in percent
--- @return     Number containing buffer memory in percent
--- @return     Number containing cache memory in percent
 function sysinfo()
        local c1 = "cat /proc/cpuinfo|grep system\\ typ|cut -d: -f2 2>/dev/null"
        local c2 = "uname -m 2>/dev/null"
@@ -139,13 +136,10 @@ function sysinfo()
 
        local system = luci.util.trim(luci.util.exec(c1))
        local model = ""
-       local memtotal = luci.util.trim(luci.util.exec(c5))
-       local memcached = luci.util.trim(luci.util.exec(c6))
-       local memfree = luci.util.trim(luci.util.exec(c7))
-       local membuffers = luci.util.trim(luci.util.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)
+       local memtotal = tonumber(luci.util.trim(luci.util.exec(c5)))
+       local memcached = tonumber(luci.util.trim(luci.util.exec(c6)))
+       local memfree = tonumber(luci.util.trim(luci.util.exec(c7)))
+       local membuffers = tonumber(luci.util.trim(luci.util.exec(c8)))
 
        if system == "" then
                system = luci.util.trim(luci.util.exec(c2))
@@ -154,7 +148,7 @@ function sysinfo()
                model = luci.util.trim(luci.util.exec(c4))
        end
 
-       return system, model, memtotal, memcached, membuffers, memfree, perc_memfree, perc_membuffers, perc_memcached
+       return system, model, memtotal, memcached, membuffers, memfree
 end
 
 --- Retrieves the output of the "logread" command.
index a4b070c..3952fb8 100644 (file)
@@ -19,7 +19,7 @@ function index()
        local i18n = luci.i18n.translate
 
        local page  = node("admin", "network")
-       page.target = template("admin_network/index")
+       page.target = alias("admin", "network", "network")
        page.title  = i18n("network")  
        page.order  = 50
        
index 21f804a..fdddf6b 100644 (file)
@@ -17,12 +17,12 @@ function index()
        luci.i18n.loadc("admin-core")
        local i18n = luci.i18n.translate
        
-       entry({"admin", "system"}, template("admin_system/index"), i18n("system"), 30)
+       entry({"admin", "system"}, alias("admin", "system", "system"), i18n("system"), 30)
+       entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system"), 1)
        entry({"admin", "system", "packages"}, call("action_packages"), i18n("a_s_packages"), 10)
        entry({"admin", "system", "packages", "ipkg"}, form("admin_system/ipkg"), i18n("a_s_p_ipkg"))
        entry({"admin", "system", "passwd"}, form("admin_system/passwd"), i18n("a_s_changepw"), 20)
        entry({"admin", "system", "sshkeys"}, form("admin_system/sshkeys"), i18n("a_s_sshkeys"), 30)
-       entry({"admin", "system", "system"}, cbi("admin_system/system"), i18n("system"), 40)
        entry({"admin", "system", "processes"}, form("admin_system/processes"), i18n("process_head"), 45)
        entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), i18n("a_s_fstab"), 50)
        entry({"admin", "system", "leds"}, cbi("admin_system/leds"), i18n("leds", "LEDs"), 60)
index 6cc5c49..9967ce9 100644 (file)
@@ -12,12 +12,40 @@ You may obtain a copy of the License at
 $Id$
 ]]--
 require("luci.http.protocol.date")
+require("luci.sys")
+require("luci.tools.webadmin")
 
 m = Map("system", translate("system"), translate("a_s_desc"))
 
 s = m:section(TypedSection, "system", "")
 s.anonymous = true
 
+local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
+local uptime = luci.sys.uptime()
+
+s:option(DummyValue, "_system", translate("system")).value = system
+s:option(DummyValue, "_cpu", translate("m_i_processor")).value = model
+
+local load1, load5, load15 = luci.sys.loadavg()
+s:option(DummyValue, "_la", translate("load")).value = 
+ string.format("%.2f, %.2f, %.2f", load1, load5, load15)
+s:option(DummyValue, "_memtotal", translate("m_i_memory")).value = 
+ string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
+  tonumber(memtotal) / 1024,
+  100 * memcached / memtotal,
+  translate("mem_cached") or "",
+  100 * membuffers / memtotal,
+  translate("mem_buffered") or "",
+  100 * memfree / memtotal,
+  translate("mem_free") or "")
+
+s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
+ os.date("%c")
+s:option(DummyValue, "_uptime", translate("m_i_uptime")).value = 
+ luci.tools.webadmin.date_format(tonumber(uptime))
+
 s:option(Value, "hostname", translate("hostname"))
 
 tz = s:option(ListValue, "timezone", translate("timezone"))
diff --git a/modules/admin-full/luasrc/view/admin_network/index.htm b/modules/admin-full/luasrc/view/admin_network/index.htm
deleted file mode 100644 (file)
index dec2864..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+header%>
-<h1><%:network%></h1>
-<p><%:a_network1%></p>
-<p><%:a_network2%></p>
-<p><%:a_network3%></p>
-<p><%:a_network4%></p>
-<p><%:a_network5%></p>
-<%+footer%>
\ No newline at end of file
diff --git a/modules/admin-full/luasrc/view/admin_system/index.htm b/modules/admin-full/luasrc/view/admin_system/index.htm
deleted file mode 100644 (file)
index 3138903..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+header%>
-<h1><%:system%></h1>
-<p><%:a_s_i_system1%></p>
-<p><%:a_s_i_system2%></p> 
-<p><%:a_s_i_system3%></p> 
-<%+footer%>
\ No newline at end of file
index 7179726..07b12f3 100644 (file)
@@ -67,8 +67,10 @@ end
 function action_status()
        local data = {}
        
-       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.system, data.model, data.memtotal, data.memcached, data.membuffers, data.memfree = luci.sys.sysinfo()
+       data.perc_memfree = math.floor((data.memfree/data.memtotal)*100)
+       data.perc_membuffers = math.floor((data.membuffers/data.memtotal)*100)
+       data.perc_memcached = math.floor((data.memcached/data.memtotal)*100)
        
        data.wifi = luci.sys.wifi.getiwconfig()