How to find out information about a LXC (Linux container) CPU & Memory Usage

To find information about CPU and memory usage of a Linux Container (LXC), you can use the following commands:

  1. CPU usage:
    lxc-info -n <container_name> | grep 'CPU use'

    This will show you the percentage of CPU utilization by the container.

  2. Memory usage:
    lxc-info -n <container_name> | grep 'Memory use'

    This will show you the amount of memory used by the container.

Note: Replace <container_name> with the name of your LXC container.

You can also use the lxc-top command to display real-time statistics for CPU, memory, and network usage for all containers on the system:

lxc-top

In addition, you can use the free command inside the container to check its memory usage:

lxc-attach -n <container_name> -- free -m

And the top command to check CPU usage:

lxc-attach -n <container_name> -- top

Leave a Comment