mirror of https://github.com/aredn/aredn.git
Added Uptime and Load Averages to the sysinfo.json file. (#61)
* Added Uptime and Load Averages to the sysinfo.json file. All code copied from Darryl, dman776. * Updated Api Version number to 1.2. Updated Api Version Number to 1.2.
This commit is contained in:
parent
135a24a8d5
commit
5ad1a14022
|
@ -209,6 +209,20 @@ function file_trim(filename, maxl)
|
|||
end
|
||||
end
|
||||
|
||||
-- secondsToClock
|
||||
function secondsToClock(seconds)
|
||||
local seconds = tonumber(seconds)
|
||||
if seconds <= 0 then
|
||||
return "00:00:00";
|
||||
else
|
||||
days = string.format("%d", math.floor(seconds/86400));
|
||||
hours = string.format("%d", math.floor(math.mod(seconds, 86400)/3600));
|
||||
mins = string.format("%02d", math.floor(math.mod(seconds,3600)/60));
|
||||
secs = string.format("%02d", math.floor(math.mod(seconds,60)));
|
||||
return days.." days, "..hours..":"..mins..":"..secs
|
||||
end
|
||||
end
|
||||
|
||||
-- table.print = pretty prints a table
|
||||
function print_r(t)
|
||||
local print_r_cache={}
|
||||
|
|
|
@ -55,7 +55,7 @@ end
|
|||
info={}
|
||||
|
||||
-- API version
|
||||
info['api_version']="1.1"
|
||||
info['api_version']="1.2"
|
||||
|
||||
-- NODE name
|
||||
css=getUciConfType("system", "system")
|
||||
|
@ -148,6 +148,16 @@ if file_exists(gsfname) then
|
|||
end
|
||||
info["grid_square"]=grid
|
||||
|
||||
-- UPTIME AND LOADAVGS
|
||||
mynix=nixio.sysinfo()
|
||||
info['sysinfo']={}
|
||||
upsecs=mynix['uptime']
|
||||
info['sysinfo']['uptime']=secondsToClock(upsecs)
|
||||
info['sysinfo']['loads']=mynix['loads']
|
||||
for n,x in ipairs(info['sysinfo']['loads']) do
|
||||
info['sysinfo']['loads'][n]=round2(x,2)
|
||||
end
|
||||
|
||||
-- INTERFACES
|
||||
local tif={}
|
||||
local ift=get_interfaces()
|
||||
|
|
Loading…
Reference in New Issue