{"modulePath":"github.com/stackvista/stackstate-process-agent","version":"v0.99.35","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package docker\n\n## Variables\n\n```go\nvar (\n\tErrMissingTarget = errors.New(\"Missing cgroup target\")\n\tErrFildNotFound  = errors.New(\"cgroup file is missing\")\n)\n```\n\n```go\nvar (\n\tErrDockerNotAvailable = errors.New(\"docker not available\")\n)\n```\n\n## Functions\n\n```go\nfunc CgroupsForPids(pids []int32) (map[string]*ContainerCgroup, error)\n```\nCgroupsForPids returns ContainerCgroup for every container that's in a Cgroup. We return as a map\\[containerID]Cgroup for easy look-up.\n\n```go\nfunc ContainersByPID(pids []int32) (map[int32]*Container, error)\n```\nGenerates a mapping of PIDs to container metadata. Optimized to limit the number of syscalls for each PID for just enough to get the data we need. Only supports Docker containers for now but the bulk of the logic is around cgroups so we could support other types without too much trouble.\n\n```go\nfunc GetHostname() (string, error)\n```\n\n## Types\n\n```go\ntype CgroupIOStat struct {\n\tContainerID string\n\tReadBytes   uint64\n\tWriteBytes  uint64\n}\n```\n\n```go\ntype CgroupMemStat struct {\n\tContainerID             string\n\tCache                   uint64\n\tRSS                     uint64\n\tRSSHuge                 uint64\n\tMappedFile              uint64\n\tPgpgin                  uint64\n\tPgpgout                 uint64\n\tPgfault                 uint64\n\tPgmajfault              uint64\n\tInactiveAnon            uint64\n\tActiveAnon              uint64\n\tInactiveFile            uint64\n\tActiveFile              uint64\n\tUnevictable             uint64\n\tHierarchicalMemoryLimit uint64\n\tTotalCache              uint64\n\tTotalRSS                uint64\n\tTotalRSSHuge            uint64\n\tTotalMappedFile         uint64\n\tTotalPgpgIn             uint64\n\tTotalPgpgOut            uint64\n\tTotalPgFault            uint64\n\tTotalPgMajFault         uint64\n\tTotalInactiveAnon       uint64\n\tTotalActiveAnon         uint64\n\tTotalInactiveFile       uint64\n\tTotalActiveFile         uint64\n\tTotalUnevictable        uint64\n\tMemUsageInBytes         uint64\n\tMemMaxUsageInBytes      uint64\n\tMemLimitInBytes         uint64\n\tMemFailCnt              uint64\n}\n```\n\n```go\ntype CgroupTimesStat struct {\n\tContainerID string\n\tSystem      float64\n\tUser        float64\n}\n```\n\n```go\ntype Container struct {\n\tType       string\n\tID         string\n\tName       string\n\tImage      string\n\tImageID    string\n\tCPULimit   float64\n\tMemLimit   uint64\n\tCreated    int64\n\tState      string\n\tHealth     string\n\tReadBytes  uint64\n\tWriteBytes uint64\n}\n```\n\n```go\nfunc GetDockerContainers() ([]*Container, error)\n```\nGetDockerContainers returns a list of Docker info for active containers using the Docker API. This requires the running user to be in the \"docker\" user group or have access to /tmp/docker.sock.\n\n```go\ntype ContainerCgroup struct {\n\tContainerID string\n\tPids        []int32\n\tPaths       map[string]string\n\tMounts      map[string]string\n}\n```\n\n```go\nfunc (c ContainerCgroup) CPU() (*CgroupTimesStat, error)\n```\nCPU returns the CPU status for this cgroup instance If the cgroup file does not exist then we just log debug return nothing.\n\n```go\nfunc (c ContainerCgroup) CPULimit() (float64, error)\n```\nCPULimit would show CPU limit for this cgroup. It does so by checking the cpu period and cpu quota config if a user does this:\n\n\tdocker run --cpus='0.5' ubuntu:latest\n\nwe should return 50% for that container If the limits files aren't available (on older version) then we'll return the default value of 100.\n\n```go\nfunc (c ContainerCgroup) IO() (*CgroupIOStat, error)\n```\nIO returns the disk read and write bytes stats for this cgroup. Format:\n\n8:0 Read 49225728 8:0 Write 9850880 8:0 Sync 0 8:0 Async 59076608 8:0 Total 59076608 252:0 Read 49094656 252:0 Write 9850880 252:0 Sync 0 252:0 Async 58945536 252:0 Total 58945536\n\n```go\nfunc (c ContainerCgroup) Mem() (*CgroupMemStat, error)\n```\nMem returns the memory statistics for a Cgroup. If the cgroup file is not availble then we return an empty stats file.\n\n","path":"github.com/stackvista/stackstate-process-agent/util/docker","name":"docker","synopsis":"","isRedistributable":true}
