commit 2112d7e620d95af040108257a79d4e5912a95347 Author: Przemysław Grondek Date: Tue Feb 25 11:54:05 2020 +0100 Init conifg diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1844b1c --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +CONFIG=cgconfig.conf cgred.conf cgrules.conf +CONFIG_DIR=/etc + +SERVICES=cgconfigparser.service cgrulesgend.service +SYSTEMD_DIR=/lib/systemd/system + +install: + cp $(CONFIG) $(CONFIG_DIR) + cp $(SERVICES) $(SYSTEMD_DIR) + $(foreach service,$(SERVICES), systemctl enable $(service);) + $(foreach service,$(SERVICES), systemctl start $(service);) + +clean: + $(foreach config,$(CONFIG), rm -i $(CONFIG_DIR)/$(config);) + $(foreach service,$(SERVICES), systemctl stop $(service);) + $(foreach service,$(SERVICES), systemctl disable $(service);) + $(foreach service,$(SERVICES), rm -i $(SYSTEMD_DIR)/$(service);) diff --git a/cgconfig.conf b/cgconfig.conf new file mode 100644 index 0000000..d5c448d --- /dev/null +++ b/cgconfig.conf @@ -0,0 +1,23 @@ +# +# Copyright IBM Corporation. 2007 +# +# Authors: Balbir Singh +# 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. +# + +group chromium { + cpu { + cpu.shares = "1000"; + } + + memory { + memory.limit_in_bytes = "1G"; + memory.soft_limit_in_bytes = "768M"; + } +} diff --git a/cgconfigparser.service b/cgconfigparser.service new file mode 100644 index 0000000..7313be1 --- /dev/null +++ b/cgconfigparser.service @@ -0,0 +1,12 @@ +[Unit] +Description=cgroup config parser +After=network.target + +[Service] +User=root +Group=root +ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf +Type=oneshot + +[Install] +WantedBy=multi-user.target diff --git a/cgred.conf b/cgred.conf new file mode 100644 index 0000000..4802879 --- /dev/null +++ b/cgred.conf @@ -0,0 +1,27 @@ +# /etc/sysconfig/cgred.conf - CGroup Rules Engine Daemon configuration file +# +# The four options listed below (CONFIG_FILE, LOG_FILE, NODAEMON, LOG) are +# the only valid ones. Defining anything else in this file will cause the +# CGroup Rules Engine program to fail. So, don't do it. + +# The pathname to the configuration file for CGroup Rules Engine +CONFIG_FILE="/etc/cgrules.conf" + +# Uncomment the following line to log to specified file instead of syslog +#LOG_FILE="/var/log/cgrulesengd.log" + +# Uncomment the second line to run CGroup Rules Engine in non-daemon mode +NODAEMON="" +#NODAEMON="--nodaemon" + +# Set owner of cgred socket. 'cgexec' tool should have write access there +# (either using suid and/or sgid permissions or Linux capabilities). +SOCKET_USER="" +SOCKET_GROUP="cgred" + +# Uncomment the second line to disable logging for CGroup Rules Engine +# Uncomment the third line to enable more verbose logging. +LOG="" +#LOG="--nolog" +#LOG="-v" + diff --git a/cgrules.conf b/cgrules.conf new file mode 100644 index 0000000..9d7cb17 --- /dev/null +++ b/cgrules.conf @@ -0,0 +1,12 @@ +# /etc/cgrules.conf +#The format of this file is described in cgrules.conf(5) +#manual page. +# +# Example: +# +#@student cpu,memory usergroup/student/ +#peter cpu test1/ +#% memory test2/ +# End of file +pgrondek:/usr/bin/google-chrome cpu,memory chromium +pgrondek:/home/pgrondek/bin/rambox cpu,memory chromium diff --git a/cgrulesgend.service b/cgrulesgend.service new file mode 100644 index 0000000..c87ea4c --- /dev/null +++ b/cgrulesgend.service @@ -0,0 +1,14 @@ +[Unit] +Description=cgroup rules generator +After=network.target cgconfigparser.service + +[Service] +User=root +Group=root +Type=forking +EnvironmentFile=-/etc/cgred.conf +ExecStart=/usr/sbin/cgrulesengd +Restart=on-failure + +[Install] +WantedBy=multi-user.target