8 -------------------------- Hardware -------------
9 io
.input("/proc/meminfo")
11 string.gsub(t
, "MemTotal.-(%d+).-MemFree.-(%d+).-SwapTotal.-(%d+).-SwapFree.-(%d+)",
12 function(mem
,mfree
,swap
,swapfree
)
13 local _img
=ui_redblue_img(mem
-mfree
, mfree
)
16 then muse
= string.format("%.2fGB", (mem
-mfree
)/1024/1024)
17 else muse
= string.format("%.2fMB", (mem
-mfree
)/1024)
20 if (tonumber(mem
) > 1024*1024)
21 then mem
= string.format("%.2fGB", mem
/1024/1024)
22 else mem
= string.format("%.2fMB", mem
/1024)
24 it
["j物理内存"] = _img
.."(已使用"..muse
.." / 共"..mem
..")"
25 ---------------- Swap -----------
26 local _img
=ui_redblue_img(swap
-swapfree
, swapfree
)
27 muse
= swap
- swapfree
28 if (muse
> 1024*1024) then muse
= string.format("%.2fGB", (swap
-swapfree
)/1024/1024)
29 else muse
= string.format("%.2fMB", (swap
-swapfree
)/1024)
32 if (tonumber(swap
) > 1024*1024) then swap
= string.format("%.2fGB", swap
/1024/1024)
33 else swap
= string.format("%.2fMB", swap
/1024)
35 it
["k虚拟内存"] = _img
.."(已使用"..muse
.." / 共"..swap
..")"
37 io
.input("/proc/cpuinfo")
39 string.gsub(t
, "model name.-: (.-)\n", function(v
) it
["f处理器"] = v
end)
40 string.gsub(t
, "cache size.-: (.-)\n", function(v
) it
["g处理器缓存"] = v
end)
43 -------------------------- System -------------
44 it
["a系统型号"] = "AS100 Version 0.01"
45 it
["b系统名称"] = myexec("hostname")
46 t
= myread("/proc/uptime")
47 string.gsub(t
, "(%d+)%.%d+ ", function(s
)
48 it
["d目前系统时间"] = "<strong>"..time2date(os
.date("*t",os
.date(os
.time()))).."</strong>".." (启动时间: <strong>"..time2date(os
.date("*t", os
.time()-s
)).."</strong>)"
49 it
["e已开机时间"]=sec2string(s
)
52 t
= myexec("ifconfig eth0")
53 string.gsub(t
, "inet addr:(.-)%s+Bcast.-RX.-%((.-)%).-%((.-)%)", function(ip
,rx
, tx
)
55 it
["n网络流量"] = "流入:<strong> "..rx
.."</strong> / 流出:<strong> "..tx
.."</strong>"
58 -------------------------- Network -------------
59 -------------------------- Disks -------------
60 print([[<div class="sysinfo">
62 <tr class="boxheader">
63 <td class="boxheader">系统信息</td>
67 <table border="0" width="100%" align="center">
70 for n
in pairs(it
) do table.insert(a
, n
) end
73 do print([[<tr valign="top"><td><strong>]]..string.sub(v
,2,-1).."</strong></td><td>"..it
[v
].."</td></tr>") end
75 print("</table></td></tr></table>")