Anyway to tell how many resources, cpu, I/o a container is taking up

When I have a server with many multiple containers, some use more resource than other obviously. databases, I/o etc… Presently, I have to go into htop and check each container. Is there a way to tell how many resource it is using not just disk space. Many there is a way to tell in htop.

Anyway have you guys found a better way?

sudo lxc info [containersname]
will show you Network, memory,disk and CPU usage.

Yes, thank you, I was think more along a lxc list type command showing all containers at same time.

There’s systemd-cgtop which shows

  1. number of tasks
  2. %CPU
  3. Memory
  4. Input/s
  5. Output/s
4 Likes

Super cool Simos, Looks like it does what I need.

Is this command used for all container resources or just one?

Here’s an example with the mycontainer container. It always shows processes, and groups them by the Control Group / cgroup. You would need to add up the values in the column to get, for example, the total memory use for the cgroup. There is likely a tool out there that already does that for you.

Note that by filtering per cgroup, we are able to easily group together (pun not intended) the relevant group of processes that make up a container.

$ systemd-cgtop
Control Group                                                     Tasks   %CPU   Memory  Input/s Output/s
...
lxc.payload.mycontainer1                                             11      -    91.6M        -        -
lxc.payload.mycontainer1/init.scope                                   1      -     2.0M        -        -
lxc.payload.mycontainer1/system.slice                                10      -    79.9M        -        -
lxc.payload.mycontainer1/system.slice/console-getty.service           1      -   256.0K        -        -
lxc.payload.mycontainer1/system.slice/dbus.service                    1      -     1.5M        -        -
lxc.payload.mycontainer1/system.slice/polkit.service                  3      -     3.7M        -        -
lxc.payload.mycontainer1/system.slice/system-modprobe.slice           -      -   148.0K        -        -
lxc.payload.mycontainer1/system.slice/systemd-journald.service        1      -     7.2M        -        -
lxc.payload.mycontainer1/system.slice/systemd-logind.service          1      -     1.5M        -        -
lxc.payload.mycontainer1/system.slice/systemd-networkd.service        1      -     2.4M        -        -
lxc.payload.mycontainer1/system.slice/systemd-resolved.service        1      -     4.8M        -        -
lxc.payload.mycontainer1/system.slice/systemd-udevd.service           1      -     1.7M        -        -
...

We wrote a small Python script that helps us to quickly identify the load of individual Incus instances and it also spits out a list of processes (and which instance they belong to) that cause the most load.

Sample output:

Here is the link to the script:

https://devel.blueonyx.it/trac/browser/BlueOnyx/5211R/utils/swatch/incus_load.py