mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-17 19:27:04 +00:00
Add a netstat per container
From: Daniel Lezcano <dlezcano@fr.ibm.com> Added the ability to do netstat from outside of the container to see network resources used by the container. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
9d0195cb79
commit
0387b7a0a7
@ -43,6 +43,7 @@ liblxc_la_LDFLAGS = -release @PACKAGE_VERSION@
|
|||||||
bin_SCRIPTS = \
|
bin_SCRIPTS = \
|
||||||
lxc-ps \
|
lxc-ps \
|
||||||
lxc-ls \
|
lxc-ls \
|
||||||
|
lxc-netstat \
|
||||||
lxc-checkconfig
|
lxc-checkconfig
|
||||||
|
|
||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
|
39
src/lxc/lxc-netstat.in
Normal file
39
src/lxc/lxc-netstat.in
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# set -ex
|
||||||
|
|
||||||
|
prefix=@prefix@
|
||||||
|
lxcpath=@localstatedir@/lxc
|
||||||
|
|
||||||
|
if [ ! -r $lxcpath ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "usage: $0 -n <name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $*; do
|
||||||
|
case $i in
|
||||||
|
-n)
|
||||||
|
name=$2; shift 2;;
|
||||||
|
esac
|
||||||
|
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 [ ! -f $lxcpath/$name/init ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
initpid=$(cat $lxcpath/$name/init)
|
||||||
|
|
||||||
|
mount --bind /proc/$initpid/net /proc/$$/net && exec netstat $*
|
Loading…
Reference in New Issue
Block a user