Ask Your Question
2

How can perf record be used to monitor each individual docker container by cgroup?

asked 2023-07-02 20:43:02 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-02 20:56:01 +0000

woof gravatar image

To use perf record to monitor each individual docker container through cgroup, follow these steps:

  1. Install perf on the host machine if it is not already installed.

  2. Make sure cgroups are enabled and properly set up on the host. Verify that your containers are running inside cgroups.

  3. Use the following command to start profiling a specific cgroup:

    perf record -C <cgroup_name> -a -g -- sleep <duration_seconds>
    

    Replace <cgroup_name> with the name of the cgroup you want to profile, and <duration_seconds> with the length of time you want to run the profiling.

  4. You can also profile all cgroups associated with a specific docker container using the following command:

    perf record -e <event_name> -G <container_id> -a -- sleep <duration_seconds>
    

    Replace <event_name> with the performance event(s) you want to profile and <container_id> with the ID of the docker container you want to monitor.

  5. Once the profiling is complete, use the following command to generate a report of the collected data:

    perf report
    

    This will give you a detailed breakdown of the performance data collected for the specified cgroup(s) or docker container(s).

Note: Make sure that you have the proper permissions to use perf record on the host machine. You may need to run the command with root privileges or grant permissions to the user running the command.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-02 20:43:02 +0000

Seen: 10 times

Last updated: Jul 02 '23