diff --git a/28_checking_resources/README.md b/28_checking_resources/README.md index ba3b653..46cdb84 100644 --- a/28_checking_resources/README.md +++ b/28_checking_resources/README.md @@ -3,6 +3,7 @@ Demonstrate how to use various commands to verify resource usage in the OS. TODO: +* cgroups * Open sockets * Free memory * File handles @@ -12,10 +13,33 @@ TODO: * debugfs https://github.com/raboof/nethogs + +```sh +# booted with +cat /proc/cmdline + +# built with +cat /boot/config-5.8.0-49-generic | grep CGROUP + +# global limits +systemctl show +``` + ## Check limits ```sh -ulimit -a +# limits inside a container +docker run -it ubuntu:20.04 /bin/bash -c "ulimit -a" + +# limits on host +ulimit -a + +# limits for current pid +cat /proc/$$/limits + +# show global config +systemctl show ``` + ## Disk ```sh diff --git a/34_checking_resources/CGROUPS.md b/34_checking_resources/CGROUPS.md index 1392887..75bb6dc 100644 --- a/34_checking_resources/CGROUPS.md +++ b/34_checking_resources/CGROUPS.md @@ -1,30 +1,53 @@ -https://www.linuxjournal.com/content/everything-you-need-know-about-linux-containers-part-i-linux-control-groups-and-process - -https://www.linuxjournal.com/content/everything-you-need-know-about-linux-containers-part-ii-working-linux-containers-lxc +# README +Demonstrate how to work with cgroups +## cgroups +```sh +# man pages +man cgroups -SSH in a cgroup -https://unix.stackexchange.com/questions/209199/how-to-ensure-ssh-via-cgroups-on-centos - -https://unix.stackexchange.com/questions/56538/controlling-priority-of-applications-using-cgroups - -cgroupsv2 -https://unix.stackexchange.com/questions/471476/how-do-i-check-cgroup-v2-is-installed-on-my-machine +# list filesystems and look at cgroups +cat /proc/filesystems -## Limits -docker run -it ubuntu:20.04 /bin/bash -c "ulimit -a" +# see where they a virtually mounted +mount +``` -ulimit -a +## Install tooling +```sh +# install tooling +sudo apt install cgroup-tools -cat /proc/$$/limits +# list cgroup tools +dpkg -L cgroup-tools | grep bin -## Cgroups -```sh -cat /proc/filesystems -mount ``` +## Walk the filesystem ```sh +# cgroups v1 ls /sys/fs/cgroup/ + +# cgroups v2 +ls /sys/fs/cgroup/unified ``` + +## Resources +https://medium.com/nttlabs/cgroup-v2-596d035be4d7 + + +https://opensource.com/article/20/10/cgroups + +https://www.linuxjournal.com/content/everything-you-need-know-about-linux-containers-part-i-linux-control-groups-and-process + +https://www.linuxjournal.com/content/everything-you-need-know-about-linux-containers-part-ii-working-linux-containers-lxc + + +SSH in a cgroup +https://unix.stackexchange.com/questions/209199/how-to-ensure-ssh-via-cgroups-on-centos + +https://unix.stackexchange.com/questions/56538/controlling-priority-of-applications-using-cgroups + +cgroupsv2 +https://unix.stackexchange.com/questions/471476/how-do-i-check-cgroup-v2-is-installed-on-my-machine