Skip to content

Commit d08c987

Browse files
committed
editing again lab4-advanced-system-process-monitoring.md
* translator found a few issues while translating * fixes for some missing code blocks * fixes for some contractions * fixes for some variable use inconsistencies
1 parent b3f63e9 commit d08c987

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

docs/labs/systems_administration_II/lab4-advanced_system_process_monitoring.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
author: Wale Soyinka
2+
author: Wale Soyinka
33
contributors: Steven Spencer, Ganna Zhrynova
44
tested on: All Versions
55
tags:
@@ -17,7 +17,6 @@ tags:
1717
- cgroups
1818
---
1919

20-
2120
# Lab 4: Advanced System and process monitoring
2221

2322
## Objectives
@@ -52,7 +51,7 @@ The `fuser` command in Linux is used to identify processes using files or socket
5251
touch ~/testfile.txt
5352
```
5453

55-
2. Create the script that we will use to simulate access to testfile.txt. Type:
54+
2. Create the script that we will use to simulate access to `testfile.txt`. Type:
5655

5756
```bash
5857
cat > ~/simulate_file_usage.sh << EOF
@@ -87,7 +86,7 @@ The `fuser` command in Linux is used to identify processes using files or socket
8786
fuser -v ~/testfile.txt
8887
```
8988
90-
3. All done with testfile.txt and simulate_file_usage.sh. You can now remove the files. Type:
89+
3. All done with `testfile.txt` and `simulate_file_usage.sh`. You can now remove the files. Type:
9190
9291
```bash
9392
kill %1
@@ -145,11 +144,11 @@ The `fuser` command in Linux is used to identify processes using files or socket
145144
146145
!!! tip
147146
148-
The generate_cpu_load.sh script is a simple tool for generating CPU load by calculating Pi (π) to high precision. The same calculation is done 10 times. The script accepts an integer as the parameter for specifying the number of decimal places for calculating Pi.
147+
The `generate_cpu_load.sh` script is a simple tool for generating CPU load by calculating Pi (π) to high precision. The same calculation is done 10 times. The script accepts an integer as the parameter for specifying the number of decimal places for calculating Pi.
149148
150149
#### To simulate extra CPU load
151150
152-
1. Let's run a simple test and calculate Pi to 50 decimal places. Run the Script by typing:
151+
1. Run a simple test and calculate Pi to 50 decimal places. Run the Script by typing:
153152
154153
```bash
155154
~/generate_cpu_load.sh 50 &
@@ -197,7 +196,7 @@ The `fuser` command in Linux is used to identify processes using files or socket
197196
sudo perf stat -e cycles find /proc
198197
```
199198
200-
3. Do the same thing but with the ./generate_cpu_load.sh script. Count specific events like CPU cycles to evaluate the performance of the ./generate_cpu_load.sh script. Type:
199+
3. Do the same thing but with the `generate_cpu_load.sh` script. Count specific events like CPU cycles to evaluate the performance of the `generate_cpu_load.sh` script. Type:
201200
202201
```bash
203202
sudo perf stat -e cycles ./generate_cpu_load.sh 500
@@ -222,7 +221,7 @@ The `fuser` command in Linux is used to identify processes using files or socket
222221
223222
!!! note
224223
225-
Here's the breakdown of the final sample output of the `perf stat` command:
224+
Here is the breakdown of the final sample output of the `perf stat` command:
226225
227226
*1,670,638,886 cycles*: This indicates the total number of CPU cycles consumed during the execution of the script. Each cycle represents a single step in the CPU's instruction execution.
228227
@@ -267,7 +266,7 @@ The `fuser` command in Linux is used to identify processes using files or socket
267266
~/strace_script.sh &
268267
```
269268
270-
2. Find the PID for the `strace_script.sh` process in a separate terminal. Store the PID in a variable named MYPID. We'll use the `pgrep` command for this by running:
269+
2. Find the PID for the `strace_script.sh` process in a separate terminal. Store the PID in a variable named MYPID. Use the `pgrep` command for this by running:
271270
272271
```bash
273272
export MYPID=$(pgrep strace_script) ; echo $MYPID
@@ -309,7 +308,7 @@ The `fuser` command in Linux is used to identify processes using files or socket
309308
sudo timeout 10 strace -c -p $MYPID
310309
```
311310
312-
Our sample system shows a summary report output like this:
311+
Your sample system shows a summary report output like this:
313312
314313
OUTPUT:
315314
@@ -538,7 +537,7 @@ This exercise demonstrates direct interaction with the `cgroup` v2 filesystem.
538537
539538
#### To set a new memory resource limit
540539
541-
1. Let's set a memory resource limit to limit memory usage to 4096 bytes (4kB). To restrict processes in the `cgroup` to use a maximum of 4kB of memory type:
540+
1. Set a memory resource limit to limit memory usage to 4096 bytes (4kB). To restrict processes in the `cgroup` to use a maximum of 4kB of memory type:
542541
543542
```bash
544543
echo 4096 | sudo tee /sys/fs/cgroup/exercise_group/memory.max
@@ -564,14 +563,14 @@ This exercise demonstrates direct interaction with the `cgroup` v2 filesystem.
564563
565564
#### To run and add process/script to the memory `cgroup`
566565
567-
1. Launch the memory_stress.sh, capture its PID and add the PID to cgroup.procs. Type:
566+
1. Launch the `memory_stress.sh` script, capture its PID, and add the PID to `cgroup.procs`. Type:
568567
569568
```bash
570569
~/memory_stress.sh &
571570
echo $! | sudo tee /sys/fs/cgroup/exercise_group/cgroup.procs
572571
```
573572
574-
The /sys/fs/cgroup/exercise_group/cgroup.procs file can be used for adding or viewing the PIDs (Process IDs) of processes that are members of a given `cgroup`. Writing a PID to this file assigns the ~/memory_stress.sh script process to the exercise_group `cgroup`.
573+
Use /sys/fs/cgroup/exercise_group/cgroup.procs file for adding or viewing the PIDs (Process IDs) of processes that are members of a given `cgroup`. Writing a PID to this file assigns the `memory_stress.sh` script process to the `exercise_group` `cgroup`.
575574
576575
2. The previous command will end very quickly before completion because it has exceeded the memory limits of the `cgroup`. You can run the following `journalctl` command in another terminal to view the error as it happens. Type:
577576
@@ -597,7 +596,7 @@ This exercise demonstrates direct interaction with the `cgroup` v2 filesystem.
597596
echo 10000 | sudo tee /sys/fs/cgroup/exercise_group/cpu.max
598597
```
599598
600-
10000 represents the CPU bandwidth limit. It's set to 10% of a single CPU core's total capacity.
599+
10000 represents the CPU bandwidth limit. It is set to 10% of a single CPU core's total capacity.
601600
602601
2. Confirm CPU Limit has been set. Type:
603602
@@ -646,14 +645,14 @@ This exercise demonstrates direct interaction with the `cgroup` v2 filesystem.
646645
647646
The primary storage device can be a target for setting I/O resource limits. Storage devices on Linux systems have major and minor device numbers that can be used to identify them uniquely.
648647
649-
1. First, let's create a set of helper variables to detect and store the device number for the primary storage device on the server. Type:
648+
1. First, create a set of helper variables to detect and store the device number for the primary storage device on the server. Type:
650649
651650
```bash
652651
primary_device=$(lsblk | grep disk | awk '{print $1}' | head -n 1)
653652
primary_device_num=$(ls -l /dev/$primary_device | awk '{print $5, $6}' | sed 's/,/:/')
654653
```
655654
656-
2. Display the value of the $primary_device_num variable. Type:
655+
2. Display the value of the `$primary_device_num` variable. Type:
657656
658657
```bash
659658
echo "Primary Storage Device Number: $primary_device_num"
@@ -682,7 +681,7 @@ The primary storage device can be a target for setting I/O resource limits. Stor
682681
683682
#### To create the I/O stress test process
684683
685-
1. Start a `dd` process to create a large file named /tmp/io_stress. Also, capture and store the PID of the `dd` process in a variable named `MYPID`. Type:
684+
1. Start a `dd` process to create a large file named `/tmp/io_stress`. Also, capture and store the PID of the `dd` process in a variable named `MYPID`. Type:
686685
687686
```bash
688687
dd if=/dev/zero of=/tmp/io_stress bs=10M count=500 oflag=dsync \
@@ -705,7 +704,7 @@ The primary storage device can be a target for setting I/O resource limits. Stor
705704
iotop -p $MYPID
706705
```
707706
708-
The output will display I/O read/write speeds for the io_stress.sh process, which should not exceed 1 MB/s as per the limit.
707+
The output will display I/O read/write speeds for the io_stress.sh process, which should not exceed 1 MB/s as per the limit.
709708
710709
#### To remove `cgroups`
711710
@@ -731,7 +730,7 @@ CPU affinity binds specific processes or threads to particular CPU cores in a mu
731730
lscpu | grep "On-line"
732731
```
733732
734-
2. Let's create a sample process using the dd utility and store its PID in a MYPID variable. Type:
733+
2. Create a sample process using the `dd` utility and store its PID in a `MYPID` variable. Type:
735734
736735
```bash
737736
dd if=/dev/zero of=/dev/null & export MYPID="$!"
@@ -750,7 +749,7 @@ CPU affinity binds specific processes or threads to particular CPU cores in a mu
750749
pid 1211483's current affinity mask: f
751750
```
752751
753-
The output shows the CPU affinity mask of the process with a PID of 1211483 ($MYPID), represented in hexadecimal format. On our sample system, the affinity mask displayed is "f", which typically means that the process can run on any CPU core.
752+
The output shows the CPU affinity mask of the process with a PID of 1211483 (`$MYPID`), represented in hexadecimal format. On our sample system, the affinity mask displayed is "f", which typically means that the process can run on any CPU core.
754753
755754
!!! note
756755
@@ -765,7 +764,7 @@ CPU affinity binds specific processes or threads to particular CPU cores in a mu
765764
766765
### To set/change CPU affinity
767766
768-
1. Set the CPU affinity of the dd process to a single CPU (CPU 0). Type:
767+
1. Set the CPU affinity of the `dd` process to a single CPU (CPU 0). Type:
769768
770769
```bash
771770
taskset -p 0x1 $MYPID
@@ -784,9 +783,9 @@ CPU affinity binds specific processes or threads to particular CPU cores in a mu
784783
taskset -p $MYPID
785784
```
786785
787-
The output indicates the CPU affinity mask of the process with PID $MYPID. The affinity mask is "1" in decimal, which translates to "1" in binary. This means that the process is currently bound to CPU core 0.
786+
The output indicates the CPU affinity mask of the process with PID `$MYPID`. The affinity mask is "1" in decimal, which translates to "1" in binary. This means that the process is currently bound to CPU core 0.
788787
789-
3. Now, set the CPU affinity of the dd process to multiple CPUs (CPUs 0 and 1). Type:
788+
3. Now, set the CPU affinity of the `dd` process to multiple CPUs (CPUs 0 and 1). Type:
790789
791790
```bash
792791
taskset -p 0x3 $MYPID
@@ -809,7 +808,7 @@ CPU affinity binds specific processes or threads to particular CPU cores in a mu
809808
810809
5. Launch either the `top` or `htop` utility in a separate terminal and observe if you see anything of interest as you experiment with different `taskset` configurations for a process.
811810
812-
6. All done. Use its PID ($MYPID) to kill the `dd` process.
811+
6. All done. Use its PID (`$MYPID`) to kill the `dd` process.
813812
814813
## Exercise 9
815814
@@ -849,18 +848,18 @@ This exercise shows how to use `systemd-run` for creating transient service unit
849848
850849
!!! tip
851850
852-
`systemd.resource-control` is a configuration or management entity (concept) within the `systemd` framework designed for controlling and allocating system resources to processes and services. And `systemd.exec` is a `systemd` component responsible for defining the execution environment in which commands are executed. To view the various settings (properties) you can tweak when using systemd-run consult the `systemd.resource-control` and `systemd.exec` manual pages. This is where you will find documentation for properties like MemoryMax, CPUAccounting, IOWeight, etc.
851+
`systemd.resource-control` is a configuration or management entity (concept) within the `systemd` framework designed for controlling and allocating system resources to processes and services. And `systemd.exec` is a `systemd` component responsible for defining the execution environment in which commands are run. To view the various settings (properties) you can tweak when using `systemd-run` consult the `systemd.resource-control` and `systemd.exec` manual pages. This is where you will find documentation for properties like MemoryMax, CPUAccounting, IOWeight, etc.
853852
854853
#### To set CPU resource limit for a transient service
855854
856-
1. Let's create a transient `systemd` unit called "myrealtime.service". Run myrealtime.service with a specific round robin (rr) scheduling policy and priority. Type:
855+
1. Create a transient `systemd` unit called "myrealtime.service". Run `myrealtime.service` with a specific round robin (rr) scheduling policy and priority. Type:
857856
858857
```bash
859858
systemd-run --unit=myrealtime.service \
860859
--property=CPUSchedulingPolicy=rr --property=CPUSchedulingPriority=50 sleep 300
861860
```
862861
863-
2. View the status for myrealtime.service. Also, capture/store the main [sleep] PID in a MYPID variable. Type:
862+
2. View the status for `myrealtime.service`. Also, capture/store the main [sleep] PID in a MYPID variable. Type:
864863
865864
```bash
866865
MYPID=$(systemctl status myrealtime.service | awk '/Main PID/ {print $3}')
@@ -906,7 +905,7 @@ This exercise shows how to use `systemd-run` for creating transient service unit
906905
907906
### `schedtool`
908907
909-
This exercise demonstrates the use of `schedtool` to understand and manipulate process scheduling in Rocky Linux. We will also create a script to simulate a process for this purpose.
908+
This exercise demonstrates the use of `schedtool` to understand and manipulate process scheduling in Rocky Linux. You will also create a script to simulate a process for this purpose.
910909
911910
#### To install `schedtool`
912911
@@ -938,15 +937,15 @@ This exercise demonstrates the use of `schedtool` to understand and manipulate p
938937
~/cpu_load_generator.sh & echo $!
939938
```
940939
941-
3. Capture the PID for the main `openssl` process launched within the cpu_load_generator.sh script. Store the PID in a variable named MYPID. Type:
940+
3. Capture the PID for the main `openssl` process launched within the `cpu_load_generator.sh` script. Store the PID in a variable named `$MYPID`. Type:
942941
943942
```bash
944943
export MYPID=$(pidof openssl) ; echo $MYPID
945944
```
946945
947946
#### To use `schedtool` to check the current scheduling policy
948947
949-
1. Use the `schedtool` command to display the scheduling information of the process with PID $MYPID. Type:
948+
1. Use the `schedtool` command to display the scheduling information of the process with PID `$MYPID`. Type:
950949
951950
```bash
952951
schedtool $MYPID

0 commit comments

Comments
 (0)