--
--
--
-- Authors:
--
--
--
--
local USER_HZ = 100
local containers = {}
local stats = {}
local stats_total = {}
local max_containers
end
end
local cols = {}
local start = 1
local nextc
repeat
else
end
return cols
end
local KiB = 1024
local MiB = 1048576
local GiB = 1073741824
local TiB = 1099511627776
local PiB = 1125899906842624
local EiB = 1152921504606846976
local ZiB = 1180591620717411303424
end
end
end
end
end
end
end
end
function tty_lines()
local rows = 25
local stty_rows
break
end
end
f:close()
return rows
end
function container_sort(a, b)
end
else
end
end
end
function container_list_update()
local now_running
now_running = lxc.containers_running(true)
-- check for newly started containers
local ct = lxc.container:new(v)
containers[v] = ct
end
end
-- check for newly stopped containers
local indx = 1
local ctname = containers[indx]
containers[ctname] = nil
else
end
end
end
end
function stats_print_header(stats_total)
end
function stats_print(name, stats, stats_total)
name,
stats.cpu_use_nanos / 1000000000,
end
end
function usage()
" -h|--help print this help message\n" ..
" -m|--max display maximum number of containers\n" ..
" -d|--delay delay in seconds between refreshes (default: 3.0)\n" ..
" -s|--sort sort by [n,c,d,m] (default: n) where\n" ..
" n = Name\n" ..
" c = CPU use\n" ..
" d = Disk I/O use\n" ..
" m = Memory use\n" ..
" k = Kernel memory use\n" ..
" -r|--reverse sort in reverse (descending) order\n"
)
os.exit(1)
end
local long_opts = {
}
usage()
end
while true
do
-- may fall back to this, or ncurses. ug.
--os.execute("tput clear")
printf(TERMCLEAR)
stats_print_header(stats_total)
for index,ctname in ipairs(containers) do
stats_print(ctname, stats[ctname], stats_total)
printf("\n")
if (index >= optarg["m"]) then
break
end
end
stats_print(string.format("TOTAL (%-2d)", #containers), stats_total, stats_total)
io.flush()
core.usleep(optarg["d"] * 1000000)
end