This shows you the differences between two versions of the page.
ep:labs:01:contents:ex1 [2019/09/22 15:42] radu.mantu removed |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== T01. [15p] Vmstat ==== | ||
- | The **vmstat** utility provides a good low-overhead view of system performance. Since **vmstat** is such a low-overhead tool, it is practical to have it running even on heavily loaded servers when it is needed to monitor the system’s health. | ||
- | |||
- | === [10p] Task A - Monitoring stress === | ||
- | Run **vmstat** on your machine with a 1 second delay between updates. Notice the CPU utilization (info about the output columns [[https://medium.com/@damianmyerscough/vmstat-explained-83b3e87493b3|here]]). | ||
- | |||
- | In another terminal, use the **stress** command to start N CPU workers, where N is the number of cores on your system. | ||
- | Do not pass the number directly. In stead, use command substitution. | ||
- | |||
- | === [5p] Task B - How does it work? === | ||
- | Let us look at how **vmstat** works under the hood. We can assume that all these statistics (memory, swap, etc.) can not be normally gathered in userspace. So how does **vmstat** get these values from the kernel? Or rather, how does any process interact with the kernel? Most obvious answer: //**system calls**//. | ||
- | |||
- | <code bash> | ||
- | $ strace vmstat | ||
- | </code> | ||
- | |||
- | "All well and good. But what am I looking at?" | ||
- | |||
- | What you //should// be looking at are the system calls after the two **write**s that display the output header (hint: it has to do with **/proc/** file system). So. what are these files that **vmstat** opens? | ||
- | |||
- | <code bash> | ||
- | $ file /proc/meminfo | ||
- | $ cat /proc/meminfo | ||
- | |||
- | $ man 5 proc | ||
- | </code> | ||
- | |||
- | The manual should contain enough information about what these kernel interfaces can provide. However, if you are interested in //how// the kernel generates the statistics in **/proc/meminfo** (for example), a good place to start would be [[https://elixir.bootlin.com/linux/v4.15/source/fs/proc/meminfo.c|meminfo.c]] (but first, [[https://ocw.cs.pub.ro/courses/so2|SO2 wiki]]). | ||
- | |||
- | <solution -hidden> | ||
- | **Task A:**\\ | ||
- | <code bash> | ||
- | $ vmstat -w -n 1 | ||
- | $ stress -c $(nproc) | ||
- | </code> | ||
- | </solution> | ||