summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-08-15 05:02:35 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2008-08-15 05:02:35 +0000
commita2677981994419c6422fd6465fc60f9a0f74a8c0 (patch)
tree49e97f2395968d560d7727f2abfa7821161b28ea /scripts
parent2e25f7c8db765bed43072d4581daf17e663e20c0 (diff)
downloadlibcg-a2677981994419c6422fd6465fc60f9a0f74a8c0.zip
libcg-a2677981994419c6422fd6465fc60f9a0f74a8c0.tar.gz
libcg-a2677981994419c6422fd6465fc60f9a0f74a8c0.tar.xz
libcgroup: Add up missing scripts/samples
From: Balbir Singh <balbir@linux.vnet.ibm.com> Dhaval missed a few files while adding files to the reporsitory. Adding them in now. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@158 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'scripts')
-rw-r--r--scripts/etc/cgconfig.conf18
-rw-r--r--scripts/etc/cgconfig/cpu.conf14
-rw-r--r--scripts/etc/cgconfig/cpuacct.conf14
-rw-r--r--scripts/init.d/cgconfig163
4 files changed, 209 insertions, 0 deletions
diff --git a/scripts/etc/cgconfig.conf b/scripts/etc/cgconfig.conf
new file mode 100644
index 0000000..43f9004
--- /dev/null
+++ b/scripts/etc/cgconfig.conf
@@ -0,0 +1,18 @@
+#
+# Copyright IBM Corporation. 2008
+#
+# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# controller file
+#
+mount /tmp/cpu cpu
+mount /tmp/cpuacct cpuacct
+cpu /etc/wlm/cpu.conf
+cpuacct /etc/wlm/cpuacct.conf
diff --git a/scripts/etc/cgconfig/cpu.conf b/scripts/etc/cgconfig/cpu.conf
new file mode 100644
index 0000000..7e76dea
--- /dev/null
+++ b/scripts/etc/cgconfig/cpu.conf
@@ -0,0 +1,14 @@
+#
+# Copyright IBM Corporation. 2008
+#
+# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+class1 cpu.shares=1024 tuid=balbir tgid=balbir cuid=root cgid=root
+class2 cpu.shares=512 tuid=root tgid=root cuid=balbir cgid=balbir
diff --git a/scripts/etc/cgconfig/cpuacct.conf b/scripts/etc/cgconfig/cpuacct.conf
new file mode 100644
index 0000000..8c382e1
--- /dev/null
+++ b/scripts/etc/cgconfig/cpuacct.conf
@@ -0,0 +1,14 @@
+#
+# Copyright IBM Corporation. 2008
+#
+# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+caclass1 tuid=root tgid=root cuid=root cgid=root
+caclass2 tuid=balbir tgid=balbir cuid=balbir cgid=balbir
diff --git a/scripts/init.d/cgconfig b/scripts/init.d/cgconfig
new file mode 100644
index 0000000..1a8ca42
--- /dev/null
+++ b/scripts/init.d/cgconfig
@@ -0,0 +1,163 @@
+#
+# Start/Stop the workload manager
+#
+# Copyright IBM Corporation. 2008
+#
+# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+
+#### BEGIN INIT INFO
+# Provides: cgconfig
+# Required-Start: $local_fs $syslog $time
+# Required-Stop: $local_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: start and stop the WLM configuration
+# Description: This script allows us to create a default configuration
+#### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:.
+MOUNTS_FILE=/proc/mounts
+PROC_CGROUPS_FILE=/proc/cgroups
+CGROUP_FS=cgroup
+CONFIG_FILE=/etc/cgconfig.conf
+
+# support multiple mount points
+declare -a MOUNTPOINT
+declare -a MOUNTOPTS
+maxindex=0
+
+#
+# Source LSB routines
+#
+. /lib/lsb/init-functions
+
+parse_mounts() {
+ while read name mountpt fs opts other
+ do
+ if echo $name | grep -q $CGROUP_FS
+ then
+ maxindex=$(($maxindex+1))
+ MOUNTPOINT[$maxindex]=$mountpt
+ MOUNTOPTS[$maxindex]=$opts
+ fi
+ done < $MOUNTS_FILE
+
+ return 0;
+}
+
+umount_fs() {
+ for i in `seq 1 $maxindex`
+ do
+ umount ${MOUNTPOINT[$i]}
+ rmdir ${MOUNTPOINT[$i]}
+ done
+}
+
+start() {
+ if [ -f /var/lock/cgconfig ]
+ then
+ log_warning_msg "lock file already exists"
+ return
+ fi
+
+ if [ $? -eq 0 ]
+ then
+ log_progress_msg "Starting cgconfig service: "
+ cgconfigparser -l $CONFIG_FILE
+ fi
+ [ $? == 0 ] && touch /var/lock/cgconfig
+ return $?
+}
+
+move_all_to_init_class() {
+ for i in `seq 1 $maxindex`
+ do
+ cd ${MOUNTPOINT[$i]}
+ cat /proc/mounts | grep -wq ${MOUNTPOINT[$i]}
+ if [ $? -ne 0 ]
+ then
+ log_failure_msg "resource control filesystem not mounted"
+ exit 1
+ fi
+
+ for i in `find . -type d`
+ do
+ case $i in
+ '.')
+ ;;
+ *)
+ class=${i#./*}
+ log_progress_msg "Removing class $class"
+ sed -nu p < ./$i/tasks > tasks
+ rmdir $i
+ ;;
+ esac
+ done
+ cd - > /dev/null
+ done
+}
+
+
+stop() {
+ move_all_to_init_class
+ umount_fs
+ rm -f /var/lock/cgconfig
+}
+
+trapped() {
+ #
+ # Do nothing
+ #
+ true
+}
+
+usage() {
+ echo "$0 <start|stop>"
+ exit 1
+}
+
+common() {
+ #
+ # main script work done here
+ #
+ trap "trapped ABRT" ABRT
+ trap "trapped QUIT" QUIT
+ trap "trapped TERM" TERM
+ trap "trapped INT" INT
+
+ parse_mounts
+}
+
+case $1 in
+ 'stop')
+ common
+ stop;
+ ;;
+ 'start')
+ common
+ start;
+ ;;
+ 'restart')
+ common
+ stop
+ start
+ ;;
+ 'reload')
+ common
+ stop
+ start
+ ;;
+ *)
+ usage
+ ;;
+esac