Changed the logic of calculation of node cpu usage

This commit is contained in:
Diptanu Choudhury
2016-06-10 03:24:42 +01:00
parent 4fc5eedfa7
commit e4bad88a87

View File

@@ -406,11 +406,16 @@ func getActualResources(hostStats *api.HostStats, node *api.Node) ([]string, err
var resources []string
// Calculate cpu usage
usedCPUPercent := 0.0
for _, cpu := range hostStats.CPU {
usedCPUPercent += (cpu.User + cpu.System)
usedCPUTicks := 0.0
if freq, ok := node.Attributes["cpu.frequency"]; ok {
if clkSpeed, err := strconv.ParseFloat(freq, 64); err == nil {
for _, cpu := range hostStats.CPU {
usedCPUPercent := (cpu.User + cpu.System)
usedCPUTicks += (clkSpeed * usedCPUPercent / 100)
}
}
}
usedCPUTicks := (usedCPUPercent / 100) * float64(node.Resources.CPU)
// calculate disk usage
storageDevice := node.Attributes["unique.storage.volume"]