2015-08-06 00:19:36 +08:00
|
|
|
// +build !linux
|
|
|
|
|
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/shirou/gopsutil/cpu"
|
2016-01-10 08:17:21 +08:00
|
|
|
"github.com/shirou/gopsutil/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) {
|
|
|
|
return nil, ErrDockerNotAvailable
|
|
|
|
}
|
2015-08-06 00:19:36 +08:00
|
|
|
|
|
|
|
// GetDockerIDList returnes a list of DockerID.
|
|
|
|
// This requires certain permission.
|
|
|
|
func GetDockerIDList() ([]string, error) {
|
2015-08-07 09:14:14 +08:00
|
|
|
return nil, ErrDockerNotAvailable
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CgroupCPU returnes specified cgroup id CPU status.
|
|
|
|
// 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/
|
2016-03-22 22:09:12 +08:00
|
|
|
func CgroupCPU(containerid string, base string) (*cpu.TimesStat, error) {
|
2015-08-07 09:14:14 +08:00
|
|
|
return nil, ErrCgroupNotAvailable
|
2015-08-06 00:19:36 +08:00
|
|
|
}
|
|
|
|
|
2016-03-22 22:09:12 +08:00
|
|
|
func CgroupCPUDocker(containerid string) (*cpu.TimesStat, 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) {
|
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) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func (m CgroupMemStat) String() string {
|
|
|
|
s, _ := json.Marshal(m)
|
|
|
|
return string(s)
|
|
|
|
}
|