# sar

系统运行状态统计工具

## 补充说明

**sar命令** 是Linux下系统运行状态统计工具，它将指定的操作系统状态计数器显示到标准输出设备。sar工具将对系统当前的状态进行取样，然后通过计算数据和比例来表达系统的当前运行状态。它的特点是可以连续对系统取样，获得大量的取样数据。取样数据和分析的结果都可以存入文件，使用它时消耗的系统资源很小。

### 语法

```
sar(选项)(参数)
```

### 选项

```
-A：显示所有的报告信息；
-b：显示I/O速率；
-B：显示换页状态；
-c：显示进程创建活动；
-d：显示每个块设备的状态；
-e：设置显示报告的结束时间；
-f：从指定文件提取报告；
-i：设状态信息刷新的间隔时间；
-P：报告每个CPU的状态；
-R：显示内存状态；
-u：显示CPU利用率；
-v：显示索引节点，文件和其他内核表的状态；
-w：显示交换分区状态；
-x：显示给定进程的状态。
```

### 参数

* 间隔时间：每次报告的间隔时间（秒）；
* 次数：显示报告的次数。

### 实例

**察看内存和交换空间的使用率：**

```
sar -r
Linux 2.4.20-8 (www.jsdig.com)    20130503  
12:00:01 AM kbmemfree kbmemused  %memused 
kbmemshrd kbbuffers  kbcached  
12:10:00 AM    240468   1048252     81.34    
0    133724    485772  
12:20:00 AM    240508   1048212     81.34   
0    134172    485600  
…  
08:40:00 PM    934132    354588     27.51    
0     26080    185364  
Average:       324346    964374     74.83  
0     96072    467559
```

kbmemfree与kbmemused字段分别显示内存的未使用与已使用空间，后面跟着的是已使用空间的百分比（%memused字段）。kbbuffers与kbcached字段分别显示缓冲区与系统全域的数据存取量，单位为KB。

**观察系统部件10分钟，并对数据进行排序：**

```
sar -o temp 60 10
```


---

# 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://hezhiqiang.gitbook.io/linux/ming-ling/sar.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.
