# ServerStatBoardService
> 统计看板

---

## composeServerStatBoard
> 组合服务看板数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerStatBoardService/composeServerStatBoard`
- RPC：`rpc composeServerStatBoard (ComposeServerStatBoardRequest) returns (ComposeServerStatBoardResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）"
}
```

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

```json
{
  "minutelyPeekBandwidthBytes": "int64 // 当前带宽（N分钟峰值）",
  "dailyPeekBandwidthBytes": "int64 // 当天带宽峰值",
  "monthlyPeekBandwidthBytes": "int64 // 当月带宽峰值",
  "lastMonthlyPeekBandwidthBytes": "int64 // 上个月带宽峰值",
  "dailyCountIPs": "int64 // 当天独立IP",
  "dailyTrafficBytes": "int64 // 当天流量",
  "bandwidthPercentile": "int32",
  "minutelyBandwidthStats": "[]ServerBandwidthStat // 分钟级的带宽统计",
  "minutelyNthBandwidthStat": "ServerBandwidthStat",
  "dailyTrafficStats": "[]DailyTrafficStat",
  "hourlyTrafficStats": "[]HourlyTrafficStat",
  "topNodeStats": "[]NodeStat",
  "topCountryStats": "[]CountryStat",
  "metricDataCharts": "[]MetricDataChart",
  "day": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64",
  "countAttackRequests": "int64",
  "attackBytes": "int64",
  "hour": "string",
  "nodeId": "int64 // 节点ID",
  "nodeName": "string",
  "countryName": "string",
  "percent": "float // 流量占比"
}
```

**调用示例**

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

---

## composeServerStatNodeBoard
> 组合节点看板数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerStatBoardService/composeServerStatNodeBoard`
- RPC：`rpc composeServerStatNodeBoard (ComposeServerStatNodeBoardRequest) returns (ComposeServerStatNodeBoardResponse);`

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

```json
{
  "nodeId": "int64 // 节点ID"
}
```

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

```json
{
  "isActive": "bool",
  "trafficInBytes": "int64",
  "trafficOutBytes": "int64",
  "countRequests": "int64",
  "countAttackRequests": "int64",
  "countConnections": "int64",
  "cacheDiskSize": "int64",
  "cacheMemorySize": "int64",
  "cpuUsage": "float",
  "memoryUsage": "float",
  "memoryTotalSize": "int64",
  "load": "float",
  "monthlyTrafficBytes": "int64 // 当月流量",
  "dailyTrafficBytes": "int64 // 当日流量",
  "lastDailyTrafficBytes": "int64 // 昨日流量",
  "dailyTrafficStats": "[]DailyTrafficStat",
  "hourlyTrafficStats": "[]HourlyTrafficStat",
  "cpuNodeValues": "[]NodeValue // CPU数据",
  "memoryNodeValues": "[]NodeValue // 内存数据",
  "loadNodeValues": "[]NodeValue // 负载数据",
  "cacheDirsValues": "[]NodeValue // 缓存目录数据",
  "networkPacketsValues": "[]NodeValue // 网络数据包数据",
  "metricDataCharts": "[]MetricDataChart",
  "day": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countCachedRequests": "int64",
  "attackBytes": "int64",
  "hour": "string"
}
```

**调用示例**

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

---

## composeServerStatNodeClusterBoard
> 组合集群看板数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerStatBoardService/composeServerStatNodeClusterBoard`
- RPC：`rpc composeServerStatNodeClusterBoard (ComposeServerStatNodeClusterBoardRequest) returns (ComposeServerStatNodeClusterBoardResponse);`

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

```json
{
  "nodeClusterId": "int64 // 集群ID"
}
```

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

```json
{
  "countActiveNodes": "int64 // 在线节点",
  "countInactiveNodes": "int64 // 离线节点",
  "countServers": "int64 // 服务数量",
  "countUsers": "int64 // 用户数量",
  "monthlyTrafficBytes": "int64 // 当月流量",
  "dailyTrafficBytes": "int64 // 当日流量",
  "lastDailyTrafficBytes": "int64 // 昨日流量",
  "dailyTrafficStats": "[]DailyTrafficStat",
  "hourlyTrafficStats": "[]HourlyTrafficStat",
  "topNodeStats": "[]NodeStat",
  "cpuNodeValues": "[]NodeValue",
  "memoryNodeValues": "[]NodeValue",
  "loadNodeValues": "[]NodeValue",
  "metricDataCharts": "[]MetricDataChart // 指标图表",
  "day": "string // 日流量统计",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64",
  "countAttackRequests": "int64",
  "attackBytes": "int64",
  "hour": "string // 小时流量统计",
  "nodeId": "int64 // 节点ID",
  "nodeName": "string"
}
```

**调用示例**

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

---

## findAllEnabledServerStatBoards
> 读取所有看板

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerStatBoardService/findAllEnabledServerStatBoards`
- RPC：`rpc findAllEnabledServerStatBoards (FindAllEnabledServerStatBoardsRequest) returns (FindAllEnabledServerStatBoardsResponse);`

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

```json
{
  "nodeClusterId": "int64 // 集群ID"
}
```

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

```json
{
  "serverStatBoards": "[]ServerStatBoard"
}
```

**调用示例**

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

---
