Crate cgroup_traffic

Crate cgroup_traffic 

Source
Expand description

§cgroup_traffic

cgroup_traffic is a library to monitor the network traffic of a cgroup. By passing a pid to this library, it will attach to the cgroup of the pid and monitor the network traffic of the cgroup.

It use ebpf program BPF_PROG_TYPE_CGROUP_SKB to monitor the network traffic. Now it’s only tested for Cgroup V2. It doesn’t support Cgroup V1, because it cannot parse the path of cgroup V1.

Structs§

CgroupTransmitCounter
The CgroupTransmitCounter is a struct to monitor the network traffic of a cgroup.

Constants§

SELF
Helpful constant to monitor /proc/self/cgroup

Functions§

get_pid_cgroup
Get the cgroup path of a pid.
init_cgroup_skb_for_process_name
Initialize the eBPF program for monitoring the cgroup traffic of processes with the process name. It will attach to a group of cgroups that the processes belongs to. process_name can be grep -E pattern(EREs), like “sshd|nginx|^rust-analyzer$”.
init_cgroup_skb_monitor
Initialize the cgroup skb monitor.
list_pids_in_cgroup
List all PIDs in a cgroup.