docker

package
v1.33.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package docker contains few helper functions copied from https://github.com/docker/cli/blob/master/cli/command/container/stats_helpers.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateCPUPercentUnix

func CalculateCPUPercentUnix(previousCPU, previousSystem uint64, v *container.StatsResponse) float64

CalculateCPUPercentUnix calculate CPU usage (for Unix, in percentages)

func CalculateCPUPercentWindows

func CalculateCPUPercentWindows(v *container.StatsResponse) float64

CalculateCPUPercentWindows calculate CPU usage (for Windows, in percentages)

func CalculateMemPercentUnixNoCache

func CalculateMemPercentUnixNoCache(limit, usedNoCache float64) float64

CalculateMemPercentUnixNoCache calculate memory usage of the container, in percentages.

func CalculateMemUsageUnixNoCache

func CalculateMemUsageUnixNoCache(mem container.MemoryStats) float64

CalculateMemUsageUnixNoCache calculate memory usage of the container. Cache is intentionally excluded to avoid misinterpretation of the output.

On Docker 19.03 and older, the result is `mem.Usage - mem.Stats["cache"]`. On new docker with cgroup v1 host, the result is `mem.Usage - mem.Stats["total_inactive_file"]`. On new docker with cgroup v2 host, the result is `mem.Usage - mem.Stats["inactive_file"]`.

This definition is designed to be consistent with past values and the latest docker CLI * https://github.com/docker/cli/blob/6e2838e18645e06f3e4b6c5143898ccc44063e3b/cli/command/container/stats_helpers.go#L239

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL