feat(k8s): M14 Namespace 管理看板(资源配额 + 命名空间 CRUD)
- 后端: ListNamespacesDetailed/CreateNamespace/DeleteNamespace/ListResourceQuotas/ListLimitRanges - 后端: GetNamespacesDetail handler (6 API calls aggregate, not N×3) - 后端: CreateNamespaceHandler + DeleteNamespaceHandler (system NS protection) - 前端: NamespaceManagementPage.tsx (~280行) — 表格+概览卡片+创建/删除弹框 - 路由: GET/POST/DELETE /:clusterCode/namespaces + GET /namespace/:ns/detail - 验证: 9/9 通过 (urllib), TS 零错误, Vite 构建成功
This commit is contained in:
1 parent
c7b61968bc
commit
8240a88a84
33 files changed
+2029
-71
No files matched your search
+13
-2
@@ -18,8 +18,9 @@ import (
|
||||
|
||||
// cpuSample 保存某一时刻 CPU 的累计 jiffies,用于两次采样计算差值
|
||||
type cpuSample struct {
|
||||
total uint64 // 自系统启动以来 CPU 所有状态的累计 jiffies
|
||||
idle uint64 // idle + iowait 的累计 jiffies
|
||||
total uint64 // 自系统启动以来 CPU 所有状态的累计 jiffies
|
||||
idle uint64 // idle + iowait 的累计 jiffies
|
||||
iowait uint64 // iowait 单独累计 jiffies(用于计算 iowait 占比)
|
||||
}
|
||||
|
||||
// CPUCollector CPU 指标采集器。
|
||||
@@ -50,12 +51,18 @@ func (c *CPUCollector) Collect() (model.CPUStat, error) {
|
||||
if c.prev != nil {
|
||||
totalDelta := cur.total - c.prev.total
|
||||
idleDelta := cur.idle - c.prev.idle
|
||||
iowaitDelta := cur.iowait - c.prev.iowait
|
||||
if totalDelta > 0 {
|
||||
// 使用率 = (总增量 - 空闲增量) / 总增量 * 100
|
||||
stat.UsagePercent = float64(totalDelta-idleDelta) / float64(totalDelta) * 100.0
|
||||
if stat.UsagePercent < 0 {
|
||||
stat.UsagePercent = 0
|
||||
}
|
||||
// iowait = iowait增量 / 总增量 * 100
|
||||
stat.IOWait = float64(iowaitDelta) / float64(totalDelta) * 100.0
|
||||
if stat.IOWait < 0 {
|
||||
stat.IOWait = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
c.prev = &cur
|
||||
@@ -100,6 +107,10 @@ func readCPUSample() (cpuSample, error) {
|
||||
if i == 3 || i == 4 {
|
||||
sample.idle += x
|
||||
}
|
||||
// iowait(索引4) 单独记录
|
||||
if i == 4 {
|
||||
sample.iowait += x
|
||||
}
|
||||
}
|
||||
return sample, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user