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
|
var resources []string
|
||||||
|
|
||||||
// Calculate cpu usage
|
// Calculate cpu usage
|
||||||
usedCPUPercent := 0.0
|
usedCPUTicks := 0.0
|
||||||
for _, cpu := range hostStats.CPU {
|
if freq, ok := node.Attributes["cpu.frequency"]; ok {
|
||||||
usedCPUPercent += (cpu.User + cpu.System)
|
|
||||||
|
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
|
// calculate disk usage
|
||||||
storageDevice := node.Attributes["unique.storage.volume"]
|
storageDevice := node.Attributes["unique.storage.volume"]
|
||||||
|
|
Loading…
Reference in a new issue