# NodeValueService
> 节点指标数据服务

---

## createNodeValue
> 记录数据

- 角色：`dns`, `user`, `node`
- HTTP：`POST https://backend.dooki.cloud/NodeValueService/createNodeValue`
- RPC：`rpc createNodeValue (CreateNodeValueRequest) returns (RPCSuccess);`

**请求对象 (`CreateNodeValueRequest`)**

```json
{
  "item": "string",
  "valueJSON": "bytes",
  "createdAt": "int64"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NodeValueService/createNodeValue" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## listNodeValues
> 读取数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NodeValueService/listNodeValues`
- RPC：`rpc listNodeValues (ListNodeValuesRequest) returns (ListNodeValuesResponse);`

**请求对象 (`ListNodeValuesRequest`)**

```json
{
  "role": "string",
  "nodeId": "int64 // 节点ID",
  "item": "string",
  "range": "string"
}
```

**响应对象 (`ListNodeValuesResponse`)**

```json
{
  "nodeValues": "[]NodeValue"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NodeValueService/listNodeValues" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## sumAllNodeValueStats
> 读取所有节点的最新数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NodeValueService/sumAllNodeValueStats`
- RPC：`rpc sumAllNodeValueStats(SumAllNodeValueStatsRequest) returns (SumAllNodeValueStatsResponse);`

**请求对象 (`SumAllNodeValueStatsRequest`)**

```json
{}
```

**响应对象 (`SumAllNodeValueStatsResponse`)**

```json
{
  "totalTrafficBytesPerSecond": "int64",
  "avgCPUUsage": "float",
  "maxCPUUsage": "float",
  "totalCPUCores": "int32",
  "avgMemoryUsage": "float",
  "maxMemoryUsage": "float",
  "totalMemoryBytes": "int64",
  "avgLoad1min": "float",
  "maxLoad1min": "float",
  "avgLoad5min": "float"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NodeValueService/sumAllNodeValueStats" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
