---
title: "查询主机的 OCP Agent 详情 - 云平台 OCP V4.2.1 | OceanBase 文档中心"
description: "查询主机的 OCP Agent 详情 功能说明 获取指定主机上 OCP Agent 详细信息。 调用说明 接口约束 调用者需要具备 HOST_VIEWER 权限。 请求路径 GET /compute/hosts/{hostId}/agent 请求参数 path： 参数 类型 必选 示例值 描述 hostId Long…"
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*lJTmRZ61jSUAAAAAAAAAAAAADiGDAQ/original) 云平台 OCPV 4.2.1

# 查询主机的 OCP Agent 详情

更新时间：2025-08-04 14:35:46

[编辑](https://github.com/oceanbase/ocp-doc/edit/V4.2.1/zh-CN/1900.reference-guide/200.api-reference/1400.ocpagent-management/100.queries-the-details-of-the-ocp-agent-on-a-host.md)  

## 功能说明

获取指定主机上 OCP Agent 详细信息。

## 调用说明

### 接口约束

调用者需要具备 HOST_VIEWER 权限。

### 请求路径

`GET /compute/hosts/{hostId}/agent`

### 请求参数

**path：**

| 参数 | 类型 | 必选 | 示例值 | 描述 |
| --- | --- | --- | --- | --- |
| hostId | Long | 是 | 100 | 主机 ID。 |

### 返回结果

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| successful | Boolean | 请求是否成功。 |
| timestamp | Datetime | 服务端完成请求的时间戳。 |
| duration | Integer | 服务端处理请求的时间（毫秒）。 |
| status | Integer | 符合 HTTP Status 规范的编码。 |
| traceId | String | 请求的 Trace ID，用于排查问题。 |
| server | String | 响应请求的应用服务的地址。 |
| data | Object | 详情参见 **HostAgent 信息数据结构**。 |

**HostAgent 信息数据结构**

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| id | Long | Agent ID。 |
| version | String | Agent 版本。 |
| installHome | String | Agent 安装目录。 |
| logHome | String | Agent 日志目录。 |
| lastAvailableTime | String | 最近存活时间。 |
| hostId | Long | 主机 ID。 |
| hostInnerIpAddress | String | 主机 IP。 |
| status | String | Agent 状态，可以为 AVAILABLE、RESTARTING、STOPPING、REINSTALLING、OFFLINE、DELETED。 |
| processes | Array | 详情参见 **HostAgentProcess 数据结构**。 |
| createTime | String | 创建时间。 |
| updateTime | String | 修改时间。 |

**HostAgentProcess 数据结构**

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| id | Long | Agent 进程 ID。 |
| hostId | Long | 主机 ID。 |
| alias | String | 进程别名。 |
| pid | Integer | 进程 PID。 |
| user | String | 进程用户。 |
| startCommand | String | 启动命令。 |
| ports | String | 开放端口。 |
| elapsedTime | Long | 已存活时间（秒）。 |
| lastActiveTime | String | 最近存活时间。 |
| status | String | 进程状态，包括 STOPPED、STARTED。 |
| operable | Boolean | 是否用户可操作。 |
| logFilePattern | String | 日志文件名模版。 |
| createTime | String | 创建时间。 |
| updateTime | String | 修改时间。 |

## 示例

### 请求示例

`GET /api/v2/compute/hosts/20/agent`

### 返回示例

```javascript
{
    "data": {
        "createTime": "2023-04-19T23:26:04+08:00",
        "hostId": 1,
        "hostInnerIpAddress": "xx.xx.xx.xx",
        "id": 1,
        "installHome": "/home/admin/ocp_agent",
        "lastAvailableTime": "2023-04-20T11:17:31+08:00",
        "logHome": "/home/admin/ocp_agent/log",
        "managerPort": "62888",
        "monitorPort": "62889",
        "processes": [{
            "alias": "ocp_mgragent",
            "createTime": "2023-04-19T23:26:04+08:00",
            "elapsedTime": 42690,
            "hostId": 1,
            "id": 1,
            "lastActiveTime": "2023-04-20T11:17:31+08:00",
            "logFilePattern": "/home/admin/ocp_agent/log/mgragent.log*",
            "operable": false,
            "pid": 170643,
            "ports": "62888",
            "startCommand": "/home/admin/ocp_agent/bin/ocp_mgragent",
            "status": "STARTED",
            "updateTime": "2023-04-19T23:26:04+08:00",
            "user": "root"
        },
        {
            "alias": "ocp_monagent",
            "createTime": "2023-04-19T23:26:04+08:00",
            "elapsedTime": 42690,
            "hostId": 1,
            "id": 2,
            "lastActiveTime": "2023-04-20T11:17:31+08:00",
            "logFilePattern": "/home/admin/ocp_agent/log/monagent.log*",
            "operable": false,
            "pid": 170644,
            "ports": "62889",
            "startCommand": "/home/admin/ocp_agent/bin/ocp_monagent",
            "status": "STARTED",
            "updateTime": "2023-04-19T23:26:04+08:00",
            "user": "root"
        },
        {
            "alias": "ocp_agentd",
            "createTime": "2023-04-19T23:26:04+08:00",
            "elapsedTime": 42690,
            "hostId": 1,
            "id": 3,
            "lastActiveTime": "2023-04-20T11:17:32+08:00",
            "logFilePattern": "/home/admin/ocp_agent/log/agentd.log*",
            "operable": false,
            "pid": 170637,
            "ports": null,
            "startCommand": "/home/admin/ocp_agent/bin/ocp_agentd -c /home/admin/ocp_agent/conf/agentd.yaml",
            "status": "STARTED",
            "updateTime": "2023-04-19T23:26:04+08:00",
            "user": "root"
        }],
        "status": "AVAILABLE",
        "updateTime": "2023-04-20T11:17:31+08:00",
        "version": "4.1.0-20230419214837"
    },
    "duration": 15,
    "server": "a322af9644",
    "status": 200,
    "successful": true,
    "timestamp": "2023-04-20T11:17:35.298+08:00",
    "traceId": "365eedcd17b84fd5"
}

```

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
