usage report reserved memory (#7525)

This commit is contained in:
wanyaoqi
2020-08-10 15:40:43 +08:00
committed by GitHub
parent 5c4e157e8b
commit 54ff56c04e
2 changed files with 17 additions and 12 deletions
+16 -12
View File
@@ -2364,12 +2364,13 @@ type HostStat struct {
}
type HostsCountStat struct {
StorageSize int64
Count int64
Memory int64
MemoryVirtual float64
CPU int64
CPUVirtual float64
StorageSize int64
Count int64
Memory int64
MemoryVirtual float64
MemoryReserved int64
CPU int64
CPUVirtual float64
}
func (manager *SHostManager) calculateCount(q *sqlchemy.SQuery) HostsCountStat {
@@ -2387,6 +2388,7 @@ func (manager *SHostManager) calculateCount(q *sqlchemy.SQuery) HostsCountStat {
tCnt int64 = 0
tMem int64 = 0
tVmem float64 = 0.0
rMem int64 = 0
tCPU int64 = 0
tVCPU float64 = 0.0
)
@@ -2413,16 +2415,18 @@ func (manager *SHostManager) calculateCount(q *sqlchemy.SQuery) HostsCountStat {
if stat.CpuCmtbound <= 0.0 {
stat.CpuCmtbound = options.Options.DefaultCPUOvercommitBound
}
rMem += int64(stat.MemReserved)
tVmem += float64(float32(aMem) * stat.MemCmtbound)
tVCPU += float64(float32(aCpu) * stat.CpuCmtbound)
}
return HostsCountStat{
StorageSize: tStore,
Count: tCnt,
Memory: tMem,
MemoryVirtual: tVmem,
CPU: tCPU,
CPUVirtual: tVCPU,
StorageSize: tStore,
Count: tCnt,
Memory: tMem,
MemoryVirtual: tVmem,
MemoryReserved: rMem,
CPU: tCPU,
CPUVirtual: tVCPU,
}
}
+1
View File
@@ -690,6 +690,7 @@ func hostUsage(
count[fmt.Sprintf("%s.cpu", prefix)] = result.CPU
count[fmt.Sprintf("%s.memory.virtual", prefix)] = result.MemoryVirtual
count[fmt.Sprintf("%s.cpu.virtual", prefix)] = result.CPUVirtual
count[fmt.Sprintf("%s.memory.reserved")] = result.MemoryReserved
return count
}