5
echo "usage: $(basename $0) --name <name> [netstat options]"
11
echo "execute netstat for the specified container"
12
echo "with the added netstat options"
15
echo "name : name of the container"
16
echo "help : this current help."
18
echo "to be executed as root."
39
if [ -z "$exec" ]; then
40
exec @BINDIR@/lxc-unshare -s MOUNT -- $0 -n $name --exec "$@"
43
if [ -z "$name" ]; then
48
lxc-info -n $name 2>&1 | grep -q 'STOPPED'
50
echo "Container $name is not running"
54
cgroups=$(mount -l -t cgroup)
57
for i in "$cgroups"; do
59
cgroup_name=$(echo $i | awk ' { print $1 } ')
60
cgroup_path=$(echo $i | awk ' { print $3 } ')
62
if [ "$cgroup_name" = "lxc" ]; then
68
if [ -z "$cgroup_path" ]; then
69
cgroups=`grep -m1 -E '^[^ \t]+[ \t]+[^ \t]+[ \t]+cgroup' /proc/self/mounts`
70
for i in "$cgroups"; do
71
cgroup_path=$(echo $i | awk ' { print $2 } ')
72
if [ -n $cgroup_path ]; then
78
if [ -z "$cgroup_path" ]; then
79
echo "no cgroup mount point found"
83
# the container will be in:
84
# ${cgroup_path}.${init_cgroup_path}."lxc".$name
85
init_cgroup=`cat /proc/1/cgroup | awk -F: '{ print $3 }' | head -1`
86
final_cgroup_path=$cgroup_path/$init_cgroup/lxc
87
pid=$(head -1 $final_cgroup_path/$name/tasks)
89
if [ -z "$pid" ]; then
90
echo "no process found for '$name'"
94
mount -n --bind /proc/$pid/net /proc/$$/net && \