aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordlezcano <dlezcano>2008-10-20 11:45:19 +0000
committerdlezcano <dlezcano>2008-10-20 11:45:19 +0000
commit22e761af89d60a2eb4801865d5d33a801816a48f (patch)
tree178af49c521e3801b5b7630542a463c2fb2ef82a
parentThese modifications improve the monitoring support of the container. Now (diff)
downloadlxc-22e761af89d60a2eb4801865d5d33a801816a48f.tar.gz
lxc-22e761af89d60a2eb4801865d5d33a801816a48f.tar.bz2
lxc-22e761af89d60a2eb4801865d5d33a801816a48f.zip
This new command is a helper to check if the needed functionalities are
compiled the kernel. It relies on /proc/config.gz, if it is not compiled, the command will simply fail. If a feature is missing but not mandatory, "disabled" keyword will appear in yellow, if it is mandatory, it will appear in "red", otherwise the key word "enabled" will appear in green.
-rw-r--r--src/lxc/Makefile.am3
-rwxr-xr-xsrc/lxc/lxc-checkconfig.in54
2 files changed, 56 insertions, 1 deletions
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 2acd29a..53a0fa0 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -43,7 +43,8 @@ liblxc_la_SOURCES = \
liblxc_la_LDFLAGS = -release @PACKAGE_VERSION@
bin_SCRIPTS = \
- lxc-ps
+ lxc-ps \
+ lxc-checkconfig
bin_PROGRAMS = \
lxc-create \
diff --git a/src/lxc/lxc-checkconfig.in b/src/lxc/lxc-checkconfig.in
new file mode 100755
index 0000000..cb91688
--- /dev/null
+++ b/src/lxc/lxc-checkconfig.in
@@ -0,0 +1,54 @@
+#!/bin/bash
+CONFIGZ=/proc/config.gz
+
+SETCOLOR_SUCCESS="echo -en \\033[1;32m"
+SETCOLOR_FAILURE="echo -en \\033[1;31m"
+SETCOLOR_WARNING="echo -en \\033[1;33m"
+SETCOLOR_NORMAL="echo -en \\033[0;39m"
+
+is_enabled() {
+ mandatory=$2
+ zgrep -q "$1=y" $CONFIGZ
+ RES=$?
+
+ if [ $RES = 0 ]; then
+ $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+ else
+ if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
+ $SETCOLOR_FAILURE && echo -e "disabled" && $SETCOLOR_NORMAL
+ else
+ $SETCOLOR_WARNING && echo -e "disabled" && $SETCOLOR_NORMAL
+ fi
+ fi
+}
+
+if [ ! -f $CONFIGZ ]; then
+ echo
+ echo "The kernel configuration can not be retrieved because"
+ echo "\"$CONFIGZ\" was not found."
+ echo
+ echo "Is your kernel compiled with IKCONFIG_PROC ?"
+ echo
+ exit 1
+fi
+
+echo "--- Namespaces ---"
+echo -n "Namespaces: " && is_enabled CONFIG_NAMESPACES yes
+echo -n "Utsname namespace: " && is_enabled CONFIG_UTS_NS
+echo -n "Ipc namespace: " && is_enabled CONFIG_IPC_NS yes
+echo -n "Pid namespace: " && is_enabled CONFIG_PID_NS yes
+echo -n "User namespace: " && is_enabled CONFIG_USER_NS
+echo -n "Network namespace: " && is_enabled CONFIG_NET_NS
+echo
+echo "--- Control groups ---"
+echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS
+echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS
+echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
+echo -n "Cgroup sched: " && is_enabled CONFIG_CGROUP_SCHED
+echo -n "Cgroup cpu account: " && is_enabled CONFIG_CGROUP_CPUACCT
+echo -n "Cgroup memory controller: " && is_enabled CONFIG_CGROUP_MEM_RES_CTLR
+echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS
+echo
+echo "--- Misc ---"
+echo -n "Veth pair device: " && is_enabled CONFIG_VETH
+echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN