List memory usage for all containers indvidually

Hello,

I am aware that it is possible to list memory per container using ‘lxc info container’. Is it possible to get the memory used for all containers. What should be flag to use with lxc list -c ?

Thanks

So there’s currently no nice way to get the memory usage. It would be a pretty trivial change to add a column for it though.

Until then, you can get it with something like:

lxc list --format=json | jq '.[] | "\(.name) \(.state.memory.usage)"'

Memory and disk usage would definitely be very useful columns to add to lxc list.

Note that the ‘very trivial’ remark of @stgraber for memory use could be upgraded to ‘horribly difficult to do right’ for disk usage.

Thanks, another version removing stopped containers and changing formatting:

lxc list --format=json | jq  '.[] | "\(.name) \(.status) \(.state.memory.usage)"' | tr -d "\"" | grep -v Stopped | awk '{ printf "%-30s %10d\n", $1, $3/1000000 }'

God … keep up :roll_eyes: :stuck_out_tongue_winking_eye: