Commit Graph

48 Commits (dbc1fd4429a72085516e19416bbcb5ad8fc6b4f9)

Author SHA1 Message Date
shirou e3e69fdc1f add SPDX License, remove old build tag, and replace import
Antoine Toulme b712e59295 fix more linting reports
Antoine Toulme fe1caf758c lint fixes
Antoine Toulme 38b94668ea allow to pass context values to override environment variables
Ville Skyttä f7e1f36418 refactor: remove unnecessary exec.LookPath calls
Executing the command does the lookup if needed and returns the same
error when not found, no need to do it separately.
Matthieu MOREL b0469a470b
Merge branch 'master' into master
Ville Skyttä 1e56c6f421 Spelling and grammar fixes
Matthieu MOREL 8ba220d241 enable contextcheck linter
mmorel-35 1e6b445a8a gofumpt
shirou 0969c9436b delete v2 directory, move v3 to top #1078
renaynay 0e9462eed2
renamed CLK_TCK variables for consistency across OSs
mingrammer 017c9f9cbc Fix typos
shirou 3ec50d2876
Merge pull request #595 from liu4480/dev
add CgroupCPUUsageDocker just like CgroupCPUDocker
Bin Liu 4ef2371dda correct param in docker_linux.go for memory.stat
The version of docker on Ubuntu18.04 and Centos7 are old, and the
parameters in memory.stat on Ubuntu18.04 and Centos7 are as following:

cat /sys/fs/cgroup/memory/docker/33f962ca254969762d750ced9a97d8deef67535b96b1e8c17abd0939a3f2cbcf/memory.stat

cache 1110016
rss 413696
rss_huge 0
shmem 0
mapped_file 1015808
dirty 0
writeback 0
pgpgin 1610
pgpgout 1238
pgfault 1923
pgmajfault 12
inactive_anon 262144
active_anon 151552
inactive_file 0
active_file 1110016
unevictable 0
hierarchical_memory_limit 9223372036854771712
total_cache 1110016
total_rss 413696
total_rss_huge 0
total_shmem 0
total_mapped_file 1015808
total_dirty 0
total_writeback 0
total_pgpgin 1610
total_pgpgout 1238
total_pgfault 1923
total_pgmajfault 12
total_inactive_anon 262144
total_active_anon 151552
total_inactive_file 0
total_active_file 1110016
total_unevictable 0

this patch is for backward.
Bin Liu 601dd00812 add CgroupCPUUsageDocker just like CgroupCPUDocker
CMGS 80b3769ea3 not modify old API now
CMGS d93c01e54d get docker container cpu usage from cpuacct.usage
shirou 145dca90f7 change to use CommandContext.
Laurie Clark-Michalek 413cb32b6c Use static initialisation for invoke instances, instead of init funcs
The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
shirou e776f6384a [docker]: fix typo.
shirou a97abd3450
Merge branch 'master' into feature/add_context_support
shirou 1958326a49 [docker]: fix re-declartion
shirou cd61c36c4f
Merge branch 'master' into feature/add_context_support
shirou 231815dfea [docker]: move String() to docker.go for all platforms.
shirou 4c73494c78 Add WithContext functions.
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201
Shirou WAKAYAMA 97e1d05084 [docker]linux: add CgroupDockerStat (#189)
Shirou WAKAYAMA 613a8a90e1 fixed by golint.
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase.
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters
Masayoshi Sekimura 3a1fa5dc80 format go program with go 1.5.2 "go fmt"
Shirou WAKAYAMA 40bbba9636 docker[linux]: add more memory stats in cgroup.
cgeoffroy 40f6755c6b docker: fix static /sys paths by using env variables
Daniel Theophanes 0af895258e common: rename package common to internal/common. Add ENV helper funcs.
Package common wasn't used for public functions. Place it in an
internal directory to prevent other packages from using.

Remove the distributed references to "HOST_PROC" and "HOST_SYS"
consts and combine into a common function. This also helps so that
if a env var is defined with a trailing slash all will continue to
work as expected.

Fixes #100
Ruslan Islamgaliev 005b9b7f7d Fix imports
Ruslan Islamgaliev 91bb4ddc07 Fix docker on Centos 7
WAKAYAMA shirou abb4086531 host[freebsd]: change to use utmpx for 9.0 or later.
Shirou WAKAYAMA 1223e28905 docker[linux]: change docker error valiable and add cgroup error.
Cameron Sparr 7a2d225b30 Allow gopsutil docker to build on non-linux boxes by stubbing out non-linux libraries
Shirou WAKAYAMA feb4fc9706 docker: fix field name.
Shirou WAKAYAMA 4ead971d70 fix CPUTimes type change problem on other packages.
Jason Wilder 90c6c3ef3e Fix panic in CgroupCPU
If an invalid container ID is passed to CgroupCPU,
a panic can result.
Jason Wilder 812b04d363 Don't ignore err when getting CgroupMemDocker stats
Fixes panic: runtime error: index out of range

goroutine 10 [running]:
testing.func·006()
	/usr/local/go/src/testing/testing.go:441 +0x181
github.com/shirou/gopsutil/docker.CgroupMem(0x586b30, 0x6, 0x5a87d0, 0x1c, 0x0, 0x0, 0x0)
	/home/jwilder/go/src/github.com/shirou/gopsutil/docker/docker_linux.go:119 +0xf48
github.com/shirou/gopsutil/docker.CgroupMemDocker(0x586b30, 0x6, 0x0, 0x0, 0x0)
	/home/jwilder/go/src/github.com/shirou/gopsutil/docker/docker_linux.go:184 +0x57

If the ID passed to the CGroupMemDocker does not exist, you can get
a panic at runtime.  This can happen when a container exits before
calling the func.
Shirou WAKAYAMA 13cd195a7e change package name.
Shirou WAKAYAMA 16de570414 merge 039b9defab
Shirou WAKAYAMA a1c1d7b25f fix on Linux.
WAKAYAMA shirou d11680c773 fix bugs on FreeBSD.
Shirou WAKAYAMA a4671fcc2a move subdirectories. refer to issue #24