2021-12-23 05:54:41 +08:00
|
|
|
//go:build !linux
|
2015-08-06 00:19:36 +08:00
|
|
|
// +build !linux
|
|
|
|
|
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2017-12-31 14:25:49 +08:00
|
|
|
"context"
|
2018-09-11 15:29:08 +08:00
|
|
|
|
2021-11-06 17:53:56 +08:00
|
|
|
"github.com/shirou/gopsutil/v3/internal/common"
|
2015-08-06 00:19:36 +08:00
|
|
|
)
|
2016-04-24 16:15:45 +08:00
|
|
|
|
|
|
|
// GetDockerStat returns a list of Docker basic stats.
|
|
|
|
// This requires certain permission.
|
|
|
|
func GetDockerStat() ([]CgroupDockerStat, error) {
|
2017-12-31 14:25:49 +08:00
|
|
|
return GetDockerStatWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) {
|
2016-04-24 16:15:45 +08:00
|
|
|
return nil, ErrDockerNotAvailable
|
|
|
|
}
|
2015-08-06 00:19:36 +08:00
|
|
|
|
2022-01-31 04:48:09 +08:00
|
|
|
// GetDockerIDList returns a list of DockerID.
|
2015-08-06 00:19:36 +08:00
|
|
|
// This requires certain permission.
|
|
|
|
func GetDockerIDList() ([]string, error) {
|
2017-12-31 14:25:49 +08:00
|
|
|
return GetDockerIDListWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDockerIDListWithContext(ctx context.Context) ([]string, error) {
|
2015-08-07 09:14:14 +08:00
|
|
|
return nil, ErrDockerNotAvailable
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|
|
|
|
|
2022-01-31 04:48:09 +08:00
|
|
|
// CgroupCPU returns specified cgroup id CPU status.
|
2015-08-06 00:19:36 +08:00
|
|
|
// containerid is same as docker id if you use docker.
|
|
|
|
// If you use container via systemd.slice, you could use
|
|
|
|
// containerid = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
2021-11-06 17:53:56 +08:00
|
|
|
func CgroupCPU(containerid string, base string) (*CgroupCPUStat, error) {
|
2017-12-31 14:25:49 +08:00
|
|
|
return CgroupCPUWithContext(context.Background(), containerid, base)
|
|
|
|
}
|
|
|
|
|
2021-11-06 17:53:56 +08:00
|
|
|
func CgroupCPUWithContext(ctx context.Context, containerid string, base string) (*CgroupCPUStat, error) {
|
2015-08-07 09:14:14 +08:00
|
|
|
return nil, ErrCgroupNotAvailable
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|
|
|
|
|
2021-11-06 17:53:56 +08:00
|
|
|
func CgroupCPUDocker(containerid string) (*CgroupCPUStat, error) {
|
2017-12-31 14:25:49 +08:00
|
|
|
return CgroupCPUDockerWithContext(context.Background(), containerid)
|
|
|
|
}
|
|
|
|
|
2021-11-06 17:53:56 +08:00
|
|
|
func CgroupCPUDockerWithContext(ctx context.Context, containerid string) (*CgroupCPUStat, error) {
|
2015-11-12 20:53:18 +08:00
|
|
|
return CgroupCPU(containerid, common.HostSys("fs/cgroup/cpuacct/docker"))
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func CgroupMem(containerid string, base string) (*CgroupMemStat, error) {
|
2017-12-31 14:25:49 +08:00
|
|
|
return CgroupMemWithContext(context.Background(), containerid, base)
|
|
|
|
}
|
|
|
|
|
|
|
|
func CgroupMemWithContext(ctx context.Context, containerid string, base string) (*CgroupMemStat, error) {
|
2015-08-07 09:14:14 +08:00
|
|
|
return nil, ErrCgroupNotAvailable
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func CgroupMemDocker(containerid string) (*CgroupMemStat, error) {
|
2017-12-31 14:25:49 +08:00
|
|
|
return CgroupMemDockerWithContext(context.Background(), containerid)
|
|
|
|
}
|
|
|
|
|
|
|
|
func CgroupMemDockerWithContext(ctx context.Context, containerid string) (*CgroupMemStat, error) {
|
2015-11-12 20:53:18 +08:00
|
|
|
return CgroupMem(containerid, common.HostSys("fs/cgroup/memory/docker"))
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|