Lxc list -c <options> for root disk size

How can I include the root disk size in a column when listing containers?

Or, display the DISK USAGE option as a percentage?

I currently use;

lxc list -c ns4,limits.cpu:cpu,limits.cpu.allowance:allowance,limits.cpu.priority:priority,limits.memory:memory,MDS

Which gives me;

+--------+---------+---------------------+-----+-----------+----------+--------+---------------+------------+-----------+
|  NAME  |  STATE  |        IPV4         | CPU | ALLOWANCE | PRIORITY | MEMORY | MEMORY USAGE% | DISK USAGE | SNAPSHOTS |
+--------+---------+---------------------+-----+-----------+----------+--------+---------------+------------+-----------+

But I’d really like to see disk size and/or usage as a percentage so I can see at a glance whether disks are filling up.

The host is Ubuntu 18.04 running LXD 5.3/stable.

I don’t think the custom columns support fields from the instance state currently.

However the state info is returned in this API response:

lxc query /1.0/instances?recursion=2

So you can use something like jq to parse it how you want, e.g.

lxc query /1.0/instances?recursion=2 | jq -r 'map({name: .name, diskUsage: .state.disk.root.usage, status: .status}) | (.[0] | to_entries | map(.key)), (.[] | [.[]]) | @tsv'
name	diskUsage	status
cbuild	1773206016	Stopped

Ok thanks, I wasn’t able to find any reference to it in the docs anywhere.

All good. Cheers.

1 Like