Skip to content

Instantly share code, notes, and snippets.

@chriselsen
Created June 11, 2020 23:50
Show Gist options
  • Save chriselsen/22e2b59aaed3a9d957337bc9cfba8f72 to your computer and use it in GitHub Desktop.
Save chriselsen/22e2b59aaed3a9d957337bc9cfba8f72 to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo apt install cgroup-tools -y
sudo cp /usr/share/doc/cgroup-tools/examples/cgred.conf /etc/
sudo tee -a /etc/cgconfig.conf > /dev/null <<EOT
group bird {
cpu {
cpu.shares = "768";
}
memory {
memory.limit_in_bytes = 1536m;
}
}
EOT
sudo tee -a /etc/cgrules.conf > /dev/null <<EOT
#<user> <controllers> <destination>
bird cpu,memory bird
EOT
sudo tee -a /etc/systemd/system/cgconfigparser.service > /dev/null <<EOT
[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
EOT
sudo tee -a /etc/systemd/system/cgrulesgend.service > /dev/null <<EOT
[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
EOT
sudo systemctl daemon-reload
sudo systemctl enable cgconfigparser
sudo systemctl enable cgrulesgend
sudo systemctl start cgconfigparser
sudo systemctl start cgrulesgend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment