Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support container name or id #23

Open
keisku opened this issue Sep 28, 2024 · 0 comments
Open

Support container name or id #23

keisku opened this issue Sep 28, 2024 · 0 comments

Comments

@keisku
Copy link
Owner

keisku commented Sep 28, 2024

Add a new feature that can start monitoring by container name or container id.

This could be a workaround.

sudo gmon -path /proc/$(docker inspect -f '{{.State.Pid}}' container-name)/root/path/to/binary

Example code to get cgroup_id.

u64 get_task_cgroup_id(struct task_struct *task)
{
    struct css_set *cgroups;
    u64 cgroup_id;
    bpf_rcu_read_lock();
    cgroups = task->cgroups;
    cgroup_id = cgroups->dfl_cgrp->kn->id;
    bpf_rcu_read_unlock();
    return cgroup_id;
}
find /sys/fs/cgroup -inum <cgroup_id>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant