Merge pull request #1246 from hashicorp/fix-node-cpu-usage
Changed the logic of calculation of node cpu usage
This commit is contained in:
commit
872957e015
|
@ -406,11 +406,16 @@ func getActualResources(hostStats *api.HostStats, node *api.Node) ([]string, err
|
|||
var resources []string
|
||||
|
||||
// Calculate cpu usage
|
||||
usedCPUPercent := 0.0
|
||||
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)
|
||||
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"]
|
||||
|
|
Loading…
Reference in a new issue