Commit 5c488699 by dlezcano

List the available containers and the processes belonging to such container.

From: Daniel Lezcano <dlezcano@fr.ibm.com> This modification change the lxc-ps command and adds the lxc-ls command. The lxc-ps command takes the container name argument and shows the processes belonging to the specified container. The usual ps argument can be passed to the lxc-ps to change the output. Examples: lxc-ps -n foo --forest lxc-ps -n foo -o pid= The lxc-ls command list the container name available on the system. This is useful to retrieve information for each container. Examples: for i in $(lxc-ls); do lxc-info -n $i lxc-ps -n $i --forest done Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent e5bda9ee
...@@ -42,6 +42,7 @@ liblxc_la_LDFLAGS = -release @PACKAGE_VERSION@ ...@@ -42,6 +42,7 @@ liblxc_la_LDFLAGS = -release @PACKAGE_VERSION@
bin_SCRIPTS = \ bin_SCRIPTS = \
lxc-ps \ lxc-ps \
lxc-ls \
lxc-checkconfig lxc-checkconfig
bin_PROGRAMS = \ bin_PROGRAMS = \
......
#!/bin/bash
lxcpath=@prefix@/var/lxc
if [ ! -r $lxcpath ]; then
exit 0
fi
ls -1 $lxcpath
#!/bin/bash #!/bin/bash
# set -ex
lxcpath=@prefix@/var/lxc
LXCPATH=/var/lxc if [ ! -r $lxcpath ]; then
if [ ! -r $LXCPATH ]; then
exit 0 exit 0
fi fi
LXCS=$(ls $LXCPATH) if [ $# -eq 0 ]; then
echo "usage: $0 -n <name>"
exit 1
fi
for i in $LXCS; do for i in $*; do
if [ -d $LXCPATH/$i/nsgroup ]; then case $i in
echo "Container : $(basename $i)" -n)
cat $LXCPATH/$i/nsgroup/tasks name=$2; shift 2;;
fi esac
done done
if [ -z "$name" ]; then
echo "usage: $0 -n <name>"
exit 1
fi
if [ ! -d $lxcpath/$name ]; then
echo "'$name' does not exists"
exit 1
fi
if [ -h $lxcpath/$name/nsgroup ]; then
ps $* -p $(cat $lxcpath/$name/nsgroup/tasks)
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment