Repository navigation
feat(cluster): 扩展节点显示 CPU / 内存 / 容器内存;修本机 CPU 上限 10% - #603
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
集群页「本机」卡片有 CPU / 内存 / 进程,「扩展节点」表格没有任何宿主负载,看不出哪台节点吃紧。另外本机宿主列的 CPU 最高只能显示 10%。
变更
src/lib/cluster/node-host.mjs:一条sh -c读nproc、/proc/loadavg、/proc/meminfo(MemTotal / MemAvailable),以及 cgroup v2 下每个 Docker 容器的memory.current − inactive_file(system.slice/docker-*.scope与docker/*两种驱动目录)。口径与本机宿主列一致:CPU = load1 / 核数,内存 = MemTotal − MemAvailable。远端没有控制面进程,第三项换成「容器内存合计」(同docker stats扣缓存的算法)。ClusterManager._checkHealth:每 30 秒的健康检查里,与 Docker/info并行执行上述命令(5 秒超时,失败或读不到为null,不影响链路状态),结果写入health.host。remote-list.tsx:扩展节点表格加 CPU / 内存 / 容器三列,≥85% 标黄,悬停显示核数与 load、已用 / 总内存;链路未就绪或读不到时显示「—」。链路列加whitespace-nowrap并放宽最小宽度,窄窗口下「已连接」不再逐字竖排。panel-api.mjs hostStats():Math.round(Math.min(100, (load1 / n) * 1000) / 10)的上限写在乘 1000 之后,结果最多 10%;改为Math.round(Math.min(1000, …)) / 10。自检
biome format、webformat:check、tsc -b、eslint 通过;webvitest run全过;新增test/unit/cluster-node-host.test.mjs(解析、CPU 封顶、缺字段返回 null;Linux 上真实执行一次命令并解析)。NODE_HOST_COMMAND,输出可解析,能读到其它容器的内存。test/unit全量:本分支与 main 失败的 13 个文件、失败用例完全相同(macOS 本地环境),集群相关 65 项全过。未做