# CPU

* vmstat 1
* mpstat   #查看所有CPU 信息
* top
* pidstat      #每个进程CPU使用量
* sar -u 2 2
* perf   #可以跟着到进程内部具体函数耗时情况，并且可以指定内核函数进行统计
  * sudo yum install perf gawk (on centos install perf if no)

### perf-tools&#x20;

```
cd

git clone --depth 1 https://github.com/brendangregg/perf-tools

cd perf-tools
```

```
[root@sf-vm-1 perf-tools]# sudo ./iolatency
Tracing block I/O. Output every 1 seconds. Ctrl-C to end.

  >=(ms) .. <(ms)   : I/O      |Distribution                          |
       0 -> 1       : 0        |                                      |

  >=(ms) .. <(ms)   : I/O      |Distribution                          |
       0 -> 1       : 0        |                                      |

  >=(ms) .. <(ms)   : I/O      |Distribution                          |
       0 -> 1       : 0        |                                      |

  >=(ms) .. <(ms)   : I/O      |Distribution                          |
       0 -> 1       : 0        |                                      |

  >=(ms) .. <(ms)   : I/O      |Distribution                          |
       0 -> 1       : 3        |######################################|
```

```
[root@sf-vm-1 perf-tools]# sudo ./fs/cachestat
Counting cache functions... Output every 1 seconds.
    HITS   MISSES  DIRTIES    RATIO   BUFFERS_MB   CACHE_MB
     451        0        0   100.0%            2       3703
     452        0        0   100.0%            2       3703
     452        0        0   100.0%            2       3703
     451        0        0   100.0%            2       3703
     451        0        0   100.0%            2       3703
     451        0        0   100.0%            2       3703
     452        0        0   100.0%            2       3703
     450        0        0   100.0%            2       3703
     451        0        0   100.0%            2       3703
     451        0        0   100.0%            2       3703
^C     443        0        0   100.0%            2       3703

Ending tracing...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://toska.gitbook.io/sysadmin/linux/cpu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
