Use N=3 and M=5 by default. Override either value when the user specifies it.
Workflow
-
Calculate the latest N complete calendar days in
Asia/Shanghai, then convert the window to UTC[startTime, endTime). If the user provides explicit dates, use those dates instead. -
Run the following read-only command. Set
<host>to the DCE host provided by the user. Omit--hostnamewhen the CLI has exactly one host configured:dce business-cockpit businessvalueservice get-tenant-token-usage \ --hostname <host> \ --start-time <UTC-start> \ --end-time <UTC-end-exclusive> \ -o json
- Read the JSON
items, discard entries whosepriceis missing, non-numeric, or negative, sort bypricedescending, and keep the top M entries. Do not use the API's defaulttokenTotalordering or substitutetokenTotalfor cost. - Compute total cost, top-M cost, top-M share of total cost, and each user's cost share. Prefer
tenantNameas the user identifier, falling back totenantId. Displaypricein Chinese yuan with two decimal places. - Keep the ranking focused on cost; do not split it by model. If the API returns no valid data, state directly that the selected window contains no billable data. The final response must be in Chinese and include a conclusion, a horizontal Unicode bar chart, and a detail table using the following template.
Chinese Output Template
## 结论
最近 N 个完整自然日,费用最高的是 <用户>,费用为 ¥<金额>;Top M 用户合计占全部费用 <占比>。
## 费用排名图
1. <用户> ¥<费用> <占比>% ████████████████████
2. <用户> ¥<费用> <占比>% ████████████
## 排名明细
|排名|用户/租户|费用|费用占比|Token 总量|
|---:|---|---:|---:|---:|
|1|...|¥...|...%|...|
## 运营关注
- <费用集中度或其他重要发现>
Only run the GET query and authentication-status checks. Never run deletion, cleanup, quota-modification, or any other write operation.