File tree Expand file tree Collapse file tree 2 files changed +31
-21
lines changed Expand file tree Collapse file tree 2 files changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,22 @@ for container in $containers;do
1212 if [ " $mountpoint " = " $LXCFS_ROOT_PATH " ]; then
1313 echo " remount $container "
1414 PID=$( docker inspect --format ' {{.State.Pid}}' $container )
15- # mount /proc
16- for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do
17- echo nsenter --target $PID --mount -- mount -B " $LXCFS /proc/$file " " /proc/$file "
18- nsenter --target $PID --mount -- mount -B " $LXCFS /proc/$file " " /proc/$file "
19- done
20- # mount /sys
21- for file in online; do
22- echo nsenter --target $PID --mount -- mount -B " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
23- nsenter --target $PID --mount -- mount -B " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
24- done
25- fi
15+ if nsenter --target $PID --mount -- -- which mount > /dev/null 2>&1 ; then
16+ # mount /proc
17+ for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do
18+ echo nsenter --target $PID --mount -- mount -o bind " $LXCFS /proc/$file " " /proc/$file "
19+ nsenter --target $PID --mount -- mount -o bind " $LXCFS /proc/$file " " /proc/$file "
20+ done
21+ # mount /sys
22+ for file in online; do
23+ echo nsenter --target $PID --mount -- mount -o bind " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
24+ nsenter --target $PID --mount -- mount -o bind " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
25+ done
26+ else
27+ echo " 容器 $container 没有 mount 软件"
28+ fi
29+ else
30+ echo " 容器 $container 没有挂载 /var/lib/lxc/lxcfs"
31+ fi
2632done
2733exit 0
Original file line number Diff line number Diff line change @@ -15,17 +15,21 @@ for container in $containers; do
1515 if [ " $count " != " 0" ]; then
1616 echo " remount $container "
1717 PID=$( crictl inspect --output go-template --template ' {{- .info.pid -}}' $container )
18- # mount /proc
19- for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do
20- echo nsenter --target $PID --mount -- mount -B " $LXCFS /proc/$file " " /proc/$file "
21- nsenter --target $PID --mount -- mount -B " $LXCFS /proc/$file " " /proc/$file "
22- done
18+ if nsenter --target $PID --mount -- -- which mount > /dev/null 2>&1 ; then
19+ # mount /proc
20+ for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do
21+ echo nsenter --target $PID --mount -- mount -o bind " $LXCFS /proc/$file " " /proc/$file "
22+ nsenter --target $PID --mount -- mount -o bind " $LXCFS /proc/$file " " /proc/$file "
23+ done
2324
24- # mount /sys
25- for file in online; do
26- echo nsenter --target $PID --mount -- mount -B " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
27- nsenter --target $PID --mount -- mount -B " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
28- done
25+ # mount /sys
26+ for file in online; do
27+ echo nsenter --target $PID --mount -- mount -o bind " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
28+ nsenter --target $PID --mount -- mount -o bind " $LXCFS /sys/devices/system/cpu/$file " " /sys/devices/system/cpu/$file "
29+ done
30+ else
31+ echo " 容器 $container 没有 mount 软件"
32+ fi
2933 else
3034 echo " 容器 $container 没有挂载 /var/lib/lxc/lxcfs"
3135 fi
You can’t perform that action at this time.
0 commit comments