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:
Matthias Radestock
2016-08-25 16:14:42 +01:00
parent b209d22e08
commit e2a80cfa14
2 changed files with 3 additions and 3 deletions

View File

@@ -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
}

View File

@@ -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