SYSTEM_D = {}
setmetatable(SYSTEM_D, {__index = _G})
local _ENV = SYSTEM_D
local cpu_num = 0
local cpu_speed = 0
local os_type = ""
local os_release = ""
local load_avg = {}
local proc_total = 0
local mem_info = {}
local disk_info = {}
function get_cpu_ratio_avg()
return (load_avg["one"] or 0.1) * 100
end
function get_memory_use_ratio()
mem_info["total"] = mem_info["total"] or 1
mem_info["free"] = mem_info["free"] or 1
if mem_info["total"] == 0 then
trace("memory get error")
return 0
end
return mem_info["free"] / mem_info["total"] * 100
end
function reload_mem_loadavg()
load_avg = system_loadavg()
proc_total = system_proc_total()
mem_info = system_mem_info()
end
local function create()
cpu_num = system_cpu_num()
cpu_speed = system_cpu_speed()
os_type = system_os_type()
os_release = system_os_release()
disk_info = system_disk_info()
reload_mem_loadavg()
set_timer(1000 * 60, reload_mem_loadavg, nil, true)
end
create()