This commit is contained in:
Wang Sen Di
2025-12-16 10:03:29 +08:00
parent e957dc6ac4
commit 12efe31214
2 changed files with 16 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ __get_mount_paths_cgroup_id() {
fi
done
}
# __get_mount_paths_cgroup_id
__get_mount_paths_cgroup_id
__get_in_cgroup_ids() {
awk '$0 != 0 && $0 != 1' /sys/fs/cgroup/net_cls,net_prio/*/net_cls.classid

15
netflow/test.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
__get_mount_paths_cgroup_id() {
docker ps -q --no-trunc | while read -r cid; do
_path=$(docker inspect "$cid" --format '{{range .Mounts}}{{.Source}}{{"\n"}}{{end}}' 2>/dev/null)
if grep -q "$CACHE/$FILE_PATH_START" <<<"$_path"; then
_cmd="find /sys/fs/cgroup/ -maxdepth 2 -type d -name $cid | grep net_cls 2>/dev/null"
_cgroup_path=$(nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c "$_cmd")
_cmd_classid="cat $_cgroup_path/net_cls.classid 2>/dev/null"
_cgroup_id=$(nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c "$_cmd_classid")
echo "$_cgroup_id"
fi
done
}
__get_mount_paths_cgroup_id