# cat thread pool

原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cat-thread-pool.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cat-thread-pool.html)

译文链接 : [http://www.apache.wiki/display/Elasticsearch/cat+thread+pool](http://www.apache.wiki/display/Elasticsearch/cat+thread+pool)

贡献者 : [那伊抹微笑](/display/~wangyangting)

**thread_pool** 命令展示了集群中每一个节点的线程池的统计信息。默认情况下返回所有线程池的 **actinve**（活跃的），**queue**（队列中的）和 **reject**（拒绝的）的统计信息。

```
% curl 192.168.56.10:9200/_cat/thread_pool
0EWUhXe bulk                0 0 0
0EWUhXe fetch_shard_started 0 0 0
0EWUhXe fetch_shard_store   0 0 0
0EWUhXe flush               0 0 0
0EWUhXe force_merge         0 0 0
0EWUhXe generic             0 0 0
0EWUhXe get                 0 0 0
0EWUhXe index               0 0 0
0EWUhXe listener            0 0 0
0EWUhXe management          1 0 0
0EWUhXe refresh             0 0 0
0EWUhXe search              0 0 0
0EWUhXe snapshot            0 0 0
0EWUhXe warmer              0 0 0
```

第一列是节点名

```
node_name
0EWUhXe
```

第二列是线程池名

```
name
bulk
fetch_shard_started
fetch_shard_store
flush
force_merge
generic
get
index
listener
management
refresh
search
snapshot
warmer
```

接下来的三列是所有线程池的 **actinve**（活跃的），**queue**（队列中的）和 **reject**（拒绝的）的统计信息。

```
active queue rejected
     0     0        0
     0     0        0
     0     0        0
     0     0        0
     0     0        0
     0     0        0
     0     0        0
     0     0        0
     0     0        0
     1     0        0
     0     0        0
     0     0        0
     0     0        0
     0     0        0
```

该 **cat thread pool API** 接受一个 **`thread_pool_patterns`**URL 参数，该参数指定一个逗号分隔的正则表达式列表以匹配线程池名称。

```
% curl 'localhost:9200/_cat/thread_pool/generic?v&h=id,name,active,rejected,completed'
id                     name    active rejected completed
0EWUhXeBQtaVGlexUeVwMg generic      0        0        70
```

在这里，建议线程池的统计信息展示 **host**，**active**，**rejected** 和 **completed** 列。

所有 [built-in thread pools](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-threadpool.html "Thread Pool") 和自定义的线程池都是可用的。

## 线程池字段

对于每个线程池来说，您可以通过使用表哥中的字段名来获得详细说明。

| Field Name（字段名） | Alias（别名） | Description（描述） |
| --- | --- | --- |
| `type` | `t` | The current (*) type of thread pool (`fixed` or `scaling`) |
| `active` | `a` | The number of active threads in the current thread pool |
| `size` | `s` | The number of threads in the current thread pool |
| `queue` | `q` | The number of tasks in the queue for the current thread pool |
| `queue_size` | `qs` | The maximum number of tasks permitted in the queue for the current thread pool |
| `rejected` | `r` | The number of tasks rejected by the thread pool executor |
| `largest` | `l` | The highest number of active threads in the current thread pool |
| `completed` | `c` | The number of tasks completed by the thread pool executor |
| `min` | `mi` | The configured minimum number of active threads allowed in the current thread pool |
| `max` | `ma` | The configured maximum number of active threads allowed in the current thread pool |
| `keep_alive` | `k` | The configured keep alive time for threads |

## 其它字段

除了每个线程池的详细说明之外，它也可以方便理解线程池的内部。同样的，您可以请求响应的节点的其它详细说明。（例如 **ip**）

| Field Name（字段名） | Alias（别名） | Description（描述） |
| --- | --- | --- |
| `node_id` | `id` | The unique node ID |
| `ephemeral_id` | `eid` | The ephemeral node ID |
| `pid` | `p` | The process ID of the running node |
| `host` | `h` | The hostname for the current node |
| `ip` | `i` | The IP address for the current node |
| `port` | `po` | The bound transport port for the current node |