Skip to content

Commit

Permalink
influxdata#4375 - fix docker tests memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Mathevet committed Jul 5, 2018
1 parent 26e28ff commit 3e23835
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 4 deletions.
213 changes: 212 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/inputs/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func gatherContainerStats(
mem := calculateMemUsageUnixNoCache(stat.MemoryStats)
memLimit := float64(stat.MemoryStats.Limit)
memfields["usage"] = mem
memfields["usage_percent"] = calculateMemPercentUnixNoCache(memLimit, mem)
memfields["usage_percent"] = calculateMemPercentUnixNoCache(memLimit, float64(mem))
} else {
memfields["commit_bytes"] = stat.MemoryStats.Commit
memfields["commit_peak_bytes"] = stat.MemoryStats.CommitPeak
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/docker/stats_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func calculateCPUPercentWindows(v *types.StatsJSON) float64 {

// calculateMemUsageUnixNoCache calculate memory usage of the container.
// Page cache is intentionally excluded to avoid misinterpretation of the output.
func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 {
return float64(mem.Usage - mem.Stats["cache"])
func calculateMemUsageUnixNoCache(mem types.MemoryStats) uint64 {
return mem.Usage - mem.Stats["cache"]
}

func calculateMemPercentUnixNoCache(limit float64, usedNoCache float64) float64 {
Expand Down

0 comments on commit 3e23835

Please sign in to comment.