mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
correct host cpu metric
The host CPU metric was reported as a percentage of all available CPUs, but the limit was set to n_cpus * 100%. So on a 4-core machine the graphs and metrics-on-canvas would never show more than 1/4th usage. Now the limit is set to 100%. Fixes #1664.
This commit is contained in:
@@ -74,7 +74,7 @@ var GetUptime = func() (time.Duration, error) {
|
||||
return (time.Duration(d) * 24 * time.Hour) + (time.Duration(h) * time.Hour) + (time.Duration(m) * time.Minute), nil
|
||||
}
|
||||
|
||||
// GetCPUUsagePercent returns the percent cpu usage and max (ie #cpus * 100)
|
||||
// GetCPUUsagePercent returns the percent cpu usage and max (i.e. 100% or 0 if unavailable)
|
||||
var GetCPUUsagePercent = func() (float64, float64) {
|
||||
return 0.0, 0.0
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ var GetUptime = func() (time.Duration, error) {
|
||||
|
||||
var previousStat = linuxproc.CPUStat{}
|
||||
|
||||
// GetCPUUsagePercent returns the percent cpu usage and max (ie #cpus * 100)
|
||||
// GetCPUUsagePercent returns the percent cpu usage and max (i.e. 100% or 0 if unavailable)
|
||||
var GetCPUUsagePercent = func() (float64, float64) {
|
||||
stat, err := linuxproc.ReadStat(ProcStat)
|
||||
if err != nil {
|
||||
@@ -94,7 +94,7 @@ var GetCPUUsagePercent = func() (float64, float64) {
|
||||
idled = idle - prevIdle
|
||||
)
|
||||
previousStat = currentStat
|
||||
return float64(totald-idled) * 100. / float64(totald), float64(len(stat.CPUStats)) * 100.
|
||||
return float64(totald-idled) * 100. / float64(totald), 100.
|
||||
}
|
||||
|
||||
// GetMemoryUsageBytes returns the bytes memory usage and max
|
||||
|
||||
Reference in New Issue
Block a user