Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start a look at resource checking examples #25

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions 34_checking_resources/CGROUPS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# README
Demonstrate how to work with cgroups

## cgroups
```sh
# man pages
man cgroups

# list filesystems and look at cgroups
cat /proc/filesystems

# see where they a virtually mounted
mount
```

## Install tooling
```sh
# install tooling
sudo apt install cgroup-tools

# list cgroup tools
dpkg -L cgroup-tools | grep bin

```

## 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
101 changes: 101 additions & 0 deletions 34_checking_resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Checking Resources

Demonstrate how to use various commands to verify resource usage in the OS.

REF: [14_interrogate_resources](https://github.com/chrisguest75/sysadmin_examples/tree/master/14_interrogate_resources)

TODO:

* cgroups
* Open sockets
* Free memory
* File handles
* Look at the brenden gregg resources http://www.brendangregg.com/linuxperf.html
* Filesystem
* Procfs
* 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
# 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
# free space
df -h
```

## Sockets

```sh
# summary of all the sockets
ss -s

# listening sockets
ss -l

# listening sockets with processes
sudo ss -lp

# tcp connections with information
ss -ti
```


## Memory

```sh
free -h

vmstat
```

## IO

[sysstat](https://www.linux.com/training-tutorials/sysstat-howto-deployment-and-configuration-guide-linux-servers/)

```sh

sudo apt install sysstat

# cpu usage
mpstat -A



```



top
systemd-cgtop
systemd-analyze blame

systemctl list-units -t service

9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ Steps [README.md](./32_jq/README.md)
Demonstrates using awscli to query resources in an AWS account.
Steps [README.md](./33_awscli/README.md)

## Example 34 - Checking Resources

Demonstrate how to use various commands to verify resource usage in the OS.
Steps [README.md](./34_checking_resources/README.md)

## Example 35 - APT and DPKG

Demonstrate examples of working with APT and DPKG
Expand Down Expand Up @@ -285,9 +290,9 @@ Steps [README.md](./53_sync_files/README.md)
Demonstrate date handling in shell.
Steps [README.md](./54_date_handling/README.md)

## TODO

## TODO:
* oh-my-zsh and oh-my-bash
* Globbing
* Process Substition versus command substitution < <() < $()
* Detecting dotsourcing.
https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
Expand Down